Magento 2 Modes: Default, Developer, Production [2024]
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:
Let’s go through each of them in detail,
-
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.
-
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.
- Static view files are written to the Magento
-
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
Hopefully, the idea of Magento 2 Modes is clear with this tutorial!
You can always post any doubts on the topic in the Comments section below and I’d be happy to help.
Do not forget to rate the tutorial with 5 stars!
Thank you 🙂
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
6 Comments
This tutorial is help full for me
Hello Har Prakash,
We’re glad to know that the above solution helped you.
Thank you
I am unable to set production mode, error shown on terminal
Hey, I would be able to help you better if you could show me the error.
Hi Sanjay,
“Also, it is important to note that once the site is switched out of this mode, it can’t go back to the default mode!”
It is wrong! See here: https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-mode.html#change-to-default-mode
I’ve tried and it is possible to set ‘default’ mode in any moment.
Thanks for bringing this to my notice.