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.
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);
- 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); - The control panel’s front-end resource files won’t get cached;
- Twig’s dump() function will be enabled;
- Twig’s
debug
andstrict_variables
options will be set totrue
(see Twig’s Environment Options for more info); - The global
devMode
variable in Twig templates is set totrue
; - Verbose errors are sent when using GraphQL;
- Queue errors are reported more verbosely in the control panel;
- The Yii debug toolbar can be forced on for the request by sending the
X-Debug: enable
header;
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: