Commands, Magento2, Magento2 Commands

Magento 2 Modes: Default, Developer, Production and Maintenance

Magento 2 Modes_ Default, Developer, Production and Maintenance

In this tutorial you’ll learn different Magento 2 Modes.

Earlier, Magento 1 was operated with a single mode for development as well as production. However, the Magento 2 came with below modes.

Magento 2 Modes : Default, Developer Production and Maintenance.

Let’s review through each of them in detail.

(01) Default : As the name suggests, the default mode is when no other mode is specified. In the default mode, you can deploy the Magento application on a single server without any changes in the settings.

When you initially launch a Magento 2 site it is typically in Default mode.

This mode is a hybrid of Developer and Production and appears to be intended to ramp up the time-to-launch for base Magento 2 sites due to the ability to develop without compiling code as well as a standardized set of configurations.

  • In Default mode errors are logged at the server level so while debugging is possible, it is not ideal for development.
  • For each requested file on the site a symlink is created in the pub/static directory.
  • Static view files are first materialized and then cached.

  • (02) Developer : The mode for the developers – to do all their development tasks!. This mode is much slower on the frontend and within the site admin, with the tradeoff that it automatically compiles code and offers more advanced logging and debugging capabilities than Default or Production modes.

  • Disables static view file caching.
  • Uncaught exceptions and errors are displayed in the browser.
  • System logging is in verbose.
  • Results in the slowest performance.
  • Shows errors on the frontend.

  • (03) Production : All live Magento 2 sites should be in Production mode. This mode utilizes full page caching alongside a fully built pub folder to pull from, and is optimized to run smoothly and efficiently leading to the greatest customer experience. Debugging is more difficult in Production mode as they are logged at the server level and not displayed to the user on the frontend.

    Production mode is more secure than Default or Developer mode as well due to the fact that there is no symlink created for the pub/static folder. This means if a malicious user were to gain access to pub/static and make changes they would only be changing duplicate versions of those files which would be overwritten during the next static deploy.

  • Does not show exceptions to the user (exceptions are written to logs only).
  • Serves static view files from cache only.
  • Prevents automatic code file compilation. New or updated files are not written to the file system.
  • Does not allow you to enable or disable cache types in Magento Admin.

  • (04) Maintenance : Intended to prevent access to a Magento Commerce site while it is being updated or reconfigured.

  • Redirects site visitors to a default Service Temporarily Unavailable page.
  • When the site is in maintenance mode, the var/ directory contains the .maintenance.flag file.
  • You can configure maintenance mode to allow visitor access from a specified list of IP addresses.

  • How to check which Magento 2 mode is used in your store?

    Run the below command:

    php bin/magento deploy:mode:show

    How to change your Magento 2 site’s mode?

    Set Magento 2 Default Mode:

    Run the below command:

    php bin/magento deploy:mode:set default

    Set Magento 2 Developer Mode:

    Run the below command:

    php bin/magento deploy:mode:set developer

    Set Magento 2 Production Mode:

    Run the below command:

    php bin/magento deploy:mode:set production

    Enable Magento 2 Maintenance Mode:

    Run the below command:

    php bin/magento maintenance:enable

    Enable Magento 2 Maintenance Mode with specific ip:

    Run the below command:

    php bin/magento maintenance:enable --ip=127.0.0.0 --ip=127.0.0.1

    Disable Magento 2 Maintenance Mode:

    Run the below command:

    php bin/magento maintenance:disable

    Magento 2 Maintenance Mode Status:

    Run the below command:

    php bin/magento maintenance:status

    🙂 Happy Coding. Keep Liking & Sharing 💻

    DevDocs Home

    Tagged , , , ,