Magento Tutorials

How to Enable Developer Mode in Magento 2

When developing extensions or troubleshooting your Magento store, developer mode is the mode that you’ll want to use. Developer mode comes with various benefits such as:

  • Enhanced reporting: system logging in var/report is verbose which means an easier time troubleshooting;
  • Non-cached static files: static files are written to pub/static everytime they’re called, which means every change you make will immediately be visible on the frontend
  • Exception errors: are shown in the browser instead of being logged

All of these benefits come with a cost that is performance, so expect slower load times when you’re in this mode.

Show the Current Mode

Magento 2 platform offers default mode, developer mode and production mode. To learn the current Magento mode, you need to run this command as the Magento file system owner.

php bin/magento deploy:mode:show

And a message should be shown telling you of the current mode your Magento store is running on.

Current mode Magento
Our local Magento website is currently running on developer mode

Ways to change Magento to developer mode

With CLI

The fastest way to do this would be by running a CLI command. Make sure you have cleared generated classes and Object Manager entities like proxies to prevent unexpected errors.

After doing so, follow the following steps to change mode:

If you’re changing from production mode to developer mode, delete the contents of the var/generation and var/di directories:

rm -rf <your Magento install dir>/var/di/* <your Magento install dir>/var/generation/*

Set the mode:

php bin/magento deploy:mode:set developer

The following message should display:

Enabled developer mode

With .htaccess

As you’ve noticed above, environment variables may override your commands. In the .htaccess file located in your Magento root folder, you’ll want to pay attention to the following environment variable:

#   SetEnv MAGE_MODE developer

Remove the hashtag (#) before SetEnv and your Magento mode should now be set to developer.

With env.php

An alternative way is to go to /app/etc/ and open env.php.

env php

Similarly to .htaccess, in this file, you can also change your Magento mode by changing the value of MAGE_MODE.

Change the value of MAGE_MODE to ‘developer’ in order to enable developer mode.

Hope this helps!

For more learning resources, SimiCart has a great Magento tutorial category that you must bookmark.


Marketing Executive/ Product Designer at SimiCart