Get Free Audit

How to Switch between Deploy Modes in Magento 2

Oct 11, 2018

3501 Andrey Litvin

How to Switch between Deploy Modes in Magento 2

Magento has 3 modes of operation for deployment in a development or production environment: developer mode, production mode and default mode.

Let’s take a quick look at each of the 3 deploy modes in Magento 2.

Magento 2 developer mode

The developer mode is intended only for development. This is the mode you should use to customize and expand Magento.

  1. The symlink of the required files is published in the pub / static directory.
  2. Advanced debugging.
  3. Automatic code compilation.

Magento 2 production mode

The production mode is designed for deployment in a production system. All live sites must have production mode since full caching of web pages is used in production mode, which ensures smooth and efficient work for clients on the site.

  1. Static files are stored in cache only.
  2. Errors are never displayed to a user because they are registered in the file system.

Magento 2 default mode

The default mode is usually used when we launch the site for the first time. This is a hybrid mode between developer and production modes. It is worth noting that in the default mode there are no main characteristics for production, that is why you need to switch to developer mode or production mode. After we switch the default mode to another one, we will not be able to back up, because this mode is not intended for the long use of Magento and site support.

Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey

  1. For each requested file on the site, a symlink is created in the pub / static directory.
  2. Customers cannot see the errors. The errors are collected into reports, stored and managed on the server.

Switching modes in Magento 2

When switching to the developer mode or the production mode, I recommend clearing the contents of the following folders (be careful not to delete the .htaccess files, they register configuration changes for each directory):

  • var/cache
  • var/di
  • var/generation
  • var/view_preprocessed
  • pub/static

Here is what switching between the deploy modes looks like in the console:

bin/magento deploy:mode:set {mode} [-s|—skip-compilation]

where {mode} is a required parameter (developer or production);

[-s|—skip-compilation] is an optional parameter(it’s used for skipping the compilation when switching to the developer mode).

bin/magento deploy:mode:set developer

If everything works out well, the following line will appear in the console: Enabled developer mode.

To view the current mode, you need to use the following command: bin/magento deploy:mode:show

After that, you will see the following line: Current application mode: developer.

We can also use the following commands when developing. To see the entire list of commands offered by Magento, type the following line in the root of the location of the Magento 2 files: bin/magento

You will see the commands with descriptions that perform different functions, and we as developers will be able to use them.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *