What Dev Mode Does

devMode is intended only for local development. It should never be enabled on a public server, as it can expose parts of your system (and its users) that can otherwise be considered private.

Enabling devMode #

devMode is enabled with the general config setting of the same name…

use craft\config\GeneralConfig;

return GeneralConfig::create()
    // ... other settings
    ->devMode(true);

…or by setting the CRAFT_DEV_MODE environment variable:

# ... other environment variables
CRAFT_DEV_MODE=true

It is also on by default for new projects, so that you can use the web-based installer.

devMode Features #

With devMode enabled, you have access to extra information and tools that make working on your project (or a plugin) easier:

  • PHP errors and exceptions will be reported in the browser window, with a complete stack trace and code previews;
  • Template syntax errors will be reported in the browser with a preview of the offending template;
  • Craft will log the following items for each request (some support in Craft 3, expanded Craft 4):

    • Query string variables
    • GET query params or POST body data
    • Active cookies
    • Active session variables
  • Multi-line log messages are permitted (Craft 4 and later);

  • Info-level messages are written to logs, in addition to those of greater severity;
  • PHP warnings and notices are logged (as opposed to just PHP errors and exceptions);
  • PHP errors that happen during a request that includes an Accept: application/json header are returned (along with a stack trace) as JSON (Craft 4 and later);
  • The Yii debug toolbar can be forced on for any request that sends an X-Debug: enable header, including requests from anonymous users. The toolbar shows details about recent requests, including their database queries, logs, request data, and the contents of emails the system sent (such as password reset and account activation emails);
  • Verbose errors are sent when using GraphQL;
  • Queue errors are reported more verbosely in the control panel;
  • The control panel’s front-end resource files won’t get cached;
  • Twig’s dump() function will be enabled;
  • Twig’s debug and strict_variables options will be set to true (see Twig’s Environment Options for more info);
  • The global devMode variable in Twig templates is set to true;
  • Craft’s graphical setup wizard is enabled;

To reduce the chance of accidentally leaving devMode enabled, each page of the control panel gets a “caution tape” indicator at the bottom of the left sidebar:

Craft Control Panel, devMode enabled

Craft control panel with devMode enabled, indicated by the “caution tape” in the lower-left corner.

Applies to Craft CMS 5, Craft CMS 4, and Craft CMS 3.

Search