Configuring Totara for development

This page describes regularly-used settings for development sites, and operations that developers may need to carry out in order to make things happen in the system.

None of these settings should be turned on for a production site, they can lead to performance and security issues.

Debugguing

Enabling debugging can be done in either the config.php file by adding the following or enabled in the Development section of the quick-access menu. The setting for debug below enables DEVELOPER debugging which shows all errors/warnings/notices that occur.

$CFG->debugging = 1; $CFG->debug = (E_ALL | E_STRICT);

Debug messages are by default written to the web server logs adding the following will ensure they are output on the page. However there may be some situations where errors are still written to the webserver log, such as a problem in an event that has been triggered.

$CFG->debugdisplay = 1;

The following settings when enabled will add performance statistics to the footer of every page including page load time and DB query count.

$CFG->perfdebug = 15; $CFG->profilingenabled = true;

Other useful debugging settings:

Scheduled tasks

Scheduled tasks are run on a schedule making them hard to debug, adding this unlocks functionality to override tasks on the scheduled task page forcing them to execute the next time the cron is run.

Scheduled tasks can be run manually using the schedule_task.php cli script below is an example.

To run all pending tasks (scheduled and ad-hoc tasks):

Forcing downgrade

When switching between work-in-progress branches it can be necessary to make the system pretend that an upgrade hasn’t happened yet. Note that this doesn’t actually roll back the upgrade, it merely adjusts the database to pretend that an older version of a plugin is currently installed. Use at your own risk.

Replace totara_program with the component name that needs an earlier version number, and replace 2018112202 with that earlier version number.

Always back up your database in pre-upgrade state when writing or testing upgrade scripts.

Caching

While developing caching can cause problems when back-end changes aren't immediately reflected on a page. There are several settings we can change to reduce the caching in a development environment.

And of course all caches can be purged:

GraphQL

By default the GraphQL schema is not exposed, the following with enable access to it for debugging and prevent schema caching.

Tui assets

Tui requires a build process to bundle src files into build files. The following command will build both production and development builds.

For more information and tips for developing Vue and Tui, see Setting up your development environment in the Tui documentation.

Legacy assets

Legacy CSS requires a build process as well, as do any changes to legacy JavaScript modules.