A Detailed Discussion on Magento 2 Modes

by Fayyaz Khattak  June 26, 2017

One of the significant differences between Magento 1 and Magento 2 is the introduction of Magento Modes. These modes have different configurations of the Magento platform which affect the store’s performance and operations.

Magento 2 Modes

In Magento 1, there was a single state for both production and development, but in Magento 2, there are three primary Magento 2 modes:

  • Default Mode
  • Developer Mode
  • Production Mode

There is also another mode known as “Maintenance Mode,” but it operates very differently by preventing access to the system.

Default Mode

As the name describes, the Default mode is how Magento 2 works, if no other mode is specified. It lets you deploy Magento on a single server without changing any settings and configurations. However, the Default mode is not optimized for production.

The Default mode has the following key features:

  • Errors and Exceptions are never shown to the user. They are logged to var/reports directory at the server.
  • Symlinks to the static view files are published to the pub/static.
  • The Default mode hides custom X-Magento-* HTTP request and response headers
  • This mode is not optimized for the production environment because the static view files are first materialized and then cached.

Developer Mode

This mode is recommended for developers and is the recommended mode for the development. You should set the Magento 2 Developer mode when you need to customize and extend the platform’s functionalities. This mode is slower on the front end and the website admin.

Some other features of the Developer mode include:

  • Uncaught exceptions and errors displayed in the web browser.
  • Enhanced debugging.
  • Verbose system logging.
  • The exception is thrown in the web browser when an event subscriber cannot be invoked.
  • The exception appears in the error handler rather than being logged.
  • Automatic code compilation.

Production Mode

When your store is ready to go and has been deployed to a production server, you should set the Magento 2 in production mode. After that, you should also deploy the static view files to the Magento 2 pub/static directory because this improves the performance of the store.

In production mode

  • Static view files are not materialized. They are only served from the cache.
  • Errors are never displayed to the user. Instead, they are logged to the filesystem.

Setting Magento Modes

To change or set the Magento mode, you can use the following CLI command in your SSH Terminal:

In the above command, {mode} is the required field. It can be either production or developer. --skip-compilation is the optional parameter used to skip code compilation when you set the Magento 2 to production mode.

After changing the mode, you might want to clean the cache as well by running the following command:

See the Current Mode

The easiest way of checking what mode is active right now, run the following CLI command:

A message, similar to the following line will be displayed:

Final Thoughts

I hope now you will have a better understanding of the Magento 2 modes, as well as how to change the mode and see which mode your Magento 2 store is using.

Using the different modes for Magento 2 offers new ways for development and enhance the performance and functionality of the platform.

Cloudways always look for the new and improved ways that help Magento Community grow, so please let us know if you have any question or feedback!

Start Creating Web Apps on Managed Cloud Servers Now!

Easy Web App Deployment for Agencies, Developers and E-Commerce Industry

About Fayyaz Khattak

Fayyaz is a Magento Community Manager at Cloudways – A Managed Magento Hosting Platform. His objective is to learn & share about PHP & Magento Development in Community. Fayyaz is a food lover and enjoys driving. You can email him at m.fayyaz@cloudways.com

Stay Connected:

You Might Also Like...