Magento 2 Modes

In Magento 2, there are three primary Magento 2 modes:
- Default Mode
- Developer Mode
- Production Mode
Default Mode
As the name describes, the Default mode is how Magento 2 works by Default. This modemode is not optimized for production so never use this on a live production site.
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.
- It 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.
Features of the Developer:
- Uncaught exceptions and errors displayed in the web browser.
- Enhanced debugging.
- 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.
Features
- 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:
php bin/magento deploy:mode:set {mode} [-s|--skip-compilation]
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:
php bin/magento cache:clean
Show Current Mode
The easiest way of checking what mode is active right now, run the following CLI command:
php bin/magento deploy:mode:show
A message, similar to the following line will be displayed: Current application mode: production
Conclusion
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.