Magento 2 modes were introduced with the release of Magento 2 that improved the performance of the platform!
Here, I’ll discuss the 3 Magento 2 modes: Default, Developer and Production mode. The tutorial also includes how you can change the modes. For example, set developer mode in Magento 2! It includes how to know the current mode.
Earlier, Magento 1 was operated with a single mode for development as well as production. However, the Magento 2 came with these 3 modes, making our life simpler and better
Magento 2 Modes:
- Default
- Developer
- Production
Let’s go through each of them in detail,
Model 1: 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 launch a Magento 2 site, this is the default mode. It is the combination of developer and production mode.
- Errors are never shown to the user. They are logged to the file reports at the server.
- Static view files are first materialized and then cached. Hence this mode is not ideal for the production environment.
- Symlinks to the static view files are published to the pub/static.
Model 2: Developer
The mode for the developers – to do all their development tasks!
Though slower on the frontend and Magento admin, it automatically compiles code and feature of advanced logging and debugging. Use this mode whenever you are customizing or extending the Magento 2’s default functionalities.
- Static view files are written to the Magento
pub/static
directory every time they’re called and are not cached. - Uncaught exceptions and errors are displayed in the browser
- System logging is in verbose
- An exception is seen in the error handler rather than being logged. It means the actual errors are seen in the browser and not just the error numbers. Hence, save yourselves from tracking them down in the file reports at the server!
- An exception is thrown when an event subscriber cannot be invoked and results in faster debugging of extension conflicts.
Model 3: Production
The live Magento 2 sites are in production mode. If you are concerned about offering the best customer experience, you must switch your store to this mode. It is because the production mode uses full page caching with a fully built pub folder to pull from, that results in the smooth and efficient functioning of the store.
However, debugging is comparatively difficult in the production mode as the errors are logged in the file system and never shown to the user. Also, merged CSS and Javascript do not work in this mode.
In terms of security, the production mode is the most secure because there is no symlink created for the pub/static folder. If an unauthenticated user gets the access to pub/static to change the data, it would only be the duplicate versions of those files, overwritten during the next static deploy!
That was all about the 3 Magento 2 Modes!
It must be clear that the live Magento 2 site must be in the production mode. Earlier you switch, the better! It is easier to switch a Magento 2 site to production mode with fewer customization.
Check today itself if your Magento 2 site is in production mode or not!
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 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

Now that you are clear on Magento 2 modes and have verified that all modes are properly configured, you are ready to go live. Use Magento 2 Go Live Checklist to ensure a smooth launch.
Thank you