local_devtools is a Moodle local plugin that adds a Developer Tools dropdown to the top navigation bar for authorized users.
The dropdown provides quick admin/developer actions without leaving the current page:
- Purge all caches
- Run cron
- Run a specific scheduled task
- Toggle debug mode
When a user with the local/devtools:use capability is logged in:
- A wrench icon appears in the navbar.
- Clicking it opens a dropdown with quick actions.
- Actions are executed via Moodle external functions (AJAX).
- Success/error feedback is shown in-page.
For scheduled tasks, the plugin loads all available task classes into a searchable autocomplete selector. For debug mode, the toggle is disabled if $CFG->debug is locked in config.php.
Capability:
local/devtools:use- Risk:
RISK_CONFIG | RISK_DATALOSS - Type: write
- Context: system
- Default: allowed for the
managerarchetype
- Risk:
- AJAX services are declared in
db/services.php:local_devtools_purge_caches— no parameterslocal_devtools_run_cron— no parameterslocal_devtools_run_scheduled_task—task(string, fully-qualified class name)local_devtools_set_debug—enabled(boolean)
- All services return
{success, message, output}. - Cron and scheduled tasks are executed through CLI scripts using the configured PHP binary (
$CFG->pathtophp, fallbackphp). - CLI script resolution is handled by
classes/helper/cli_helper.php, which supports both standard and mixedpublic/webroot layouts. - Scheduled task selector is enhanced using Moodle form autocomplete.
- On successful cache purge, the page reloads and a success notice is shown via
sessionStorage. - Debug mode writes directly to the Moodle database config table; it respects forced settings from
config.php.
-
Place the plugin in:
local/devtools -
Visit:
Site administration -> Notifications -
Complete the Moodle upgrade/install flow.
After modifying amd/src/devtools.js, rebuild from the Moodle root:
npx grunt amdThis compiles amd/src/devtools.js into amd/build/devtools.min.js.
- Log in as a user with
local/devtools:use. - Click the wrench icon in the top navbar.
- Choose one of the actions:
- Purge All Caches — purges all Moodle caches and reloads the page.
- Run Cron — executes
admin/cli/cron.phpvia PHP CLI. - Run Scheduled Task — select a task from the autocomplete dropdown, then click Run Task.
- Debug mode toggle — enables/disables
DEBUG_DEVELOPERlevel. Disabled (with tooltip) when the setting is locked inconfig.php.
-
Wrench icon does not appear
- Verify the plugin is installed and upgraded.
- Verify user capability
local/devtools:use. - Rebuild AMD assets and purge caches.
-
Cron/task execution fails
- Verify CLI scripts are available/readable under
admin/cli/. - Verify PHP CLI is available (
$CFG->pathtophporphponPATH).
- Verify CLI scripts are available/readable under
-
Task autocomplete/search not showing
- Purge caches and rebuild frontend assets if needed.
- Ensure JavaScript is enabled and not blocked by browser policy.
-
Debug toggle is disabled
- The
debugsetting is locked via$CFG->config_php_settingsinconfig.php. Remove the forced value to enable the toggle.
- The