Magento 2 – How to enable developer mode


System modes available is one of the first basic things you need to know about when starting out with Magento 2. There are three primary Magento 2 modes including developer, production and default. The maintenance mode operates differently from the three others to exclusively prevent access to the system. In this tutorial, we will learn about different modes of Magento and how to enable developer mode to allow debugging in Magento

Magento 2 system modes understanding

1. Default Mode

Static File Catching
Exceptions Displayed
Exception Logged
Negative Performance Impact

The Default Mode enable you to deploy the Magento application on a single server without settings changed. Default mode, however, is not optimized for production since it negatively influences on performance.

Exceptions are not displayed to the user but being written to log files. Errors are logged to var/log folder and never been shown to users. The file changes are not visible until the generated static view files are defined. It also hides custom X- Magento-* HTTP request and response headers.

In order to either deploy Magento application on more than one server or optimize server for production, it should be changed to other modes.

2. Developer Mode

Static File Catching
Exceptions Displayed
Exception Logged
Negative Performance Impact

The Developer Mode should be selected as developing code for the Magento site. This mode is intended for development only.

The error messages are visible to the user. Static files are generated as being requested. Changes are visible immediately and uncaught exceptions are displayed in the browser. Developer Mode provides verbose logging and enables automatic code compilation. Debugging is enhanced. X- Magento-* HTTP request and response headers are shown. However, because of preceding, it results the slowest performance.

3. Production Mode

Static File Catching
Exceptions Displayed
Exception Logged
Negative Performance Impact

The Production Mode is created for deployment on a production system and this mode is customer facing. Production Mode provides highest performance among three modes mentioned. Errors are logged into the file system so that they are never been displayed to the user. It also disables static view file materialization. Therefore, the static views are not generated as being called. They are deployed using the command line tool and stored in the static directory. Any changes to view files require running the deploy tool again. As using the command line tool, it’s not necessary to write access and the static directory can have read-only permissions as Magento docroot that is more secure.

As Development Mode should never be used on a live site, web user should instead generate static content in development mode and the use the deployer.php tool to push changes to production.

4. Maintenance Mode

When you do not want to make your site available to the public during updates or other changes with a 503 shown up, Maintenance Mode is an out- of- the- box feature that should be used in Magento 2.

This mode is controlled by the method Bootstrap::assertMaintenance(). A flag file (var/.maintenance.flag) is required to enable the mode.

It also allows to specify a group of people to have access to the site while the mode is employed by placing the associated IP in var/.maintenance.ip.

Current Mode Display

You should run this command as Magento file system owner. It’s the local user account on Magento server if you have private server or the user the provider gives you to log into the server if you share hosting.

Command line:

A message is displayed:

Change to Developer Mode

1. Modes change

Comment line:

In order to skip code compilation when you change to production mode, use

2. Change to Production Mode

In order to change to Developer Mode, first you should change to Production Mode

3. Change to Developer Mode

Step 1:

First, you should clear generated classes and Object Manager entities to prevent unexpected errors. Then, you can change the modes.

Step 2:

From the Production mode, delete contents of the var/generation and var/di directories:

Set the mode using command line:

You will see the following message:

After setting the mode, you should restart the web server for it to take effect.

Rate this post


About Author

Daniel is a Magento developer with 5 years of experience with customizing Magento extensions, Magento templates. He's main author at Magento explorer

Leave A Reply