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 the request by sending the
X-Debug: enable
header; - 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
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
; - 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:
![](https://cdn.craft.cloud/032c8560-18a8-45ba-a958-a03804e5cb66/builds/9e0a5477-be77-4bfd-9a40-72052f2219a1/artifacts/dist/images/icon-loading.png)
![Craft Control Panel, devMode enabled](https://cdn.craft.cloud/032c8560-18a8-45ba-a958-a03804e5cb66/assets/post-content/craft-dev-mode.png?width=960&fit=cover&s=2cdwabO9SgwXuduOJg-0sM1hRM5jZC6dT6CF_v_pNkE)
Craft control panel with devMode enabled, indicated by the “caution tape” in the lower-left corner.