How to Enable/Disable Magento 2 Developer Mode?
Today, we’re going to teach you guys how to enable & disable developer mode in Magento 2.
The Magento 2 platform offers 3 different modes to work with.
- Default Mode
- Developer Mode
- Production Mode
Depending on your needs or situation, you’ll have to apply different modes for your Magento 2 store.
In this post, we will explain everything you need to know about Developer Mode and how to enable & disable it in your Magento 2 store.
What is Developer Mode in Magento 2?
The Developer Mode in Magento 2 is mainly used when you want to make certain customizations in your Magento 2 store or install third-party premium Magento 2 extensions.
Specifically, Magento 2 Developer Mode is useful in the following situations:
- When uncaught exceptions are noticed/seen in the browser.
- When you want to generate an exception if an event subscriber cannot be enforced.
- When you want to publish a symlink of every required file to the pub/static folder.
- When the system logging in var/report is verbal and you have to put the exception into the error handler.
How to Check the Current Mode in Magento 2?
Before you learn how to enable or disable the Developer Mode in Magento 2, it’s important to first check the current mode.
Execute the following command as a Magento 2 file system owner to check the current mode:
bin/magento deploy:mode:show
Once you execute the above command, you’ll see a message like below:
Current application mode: {mode}
Here, the {mode} will be either default, developer, or production.
How to Enable Developer Mode in Magento 2?
Now, once you have checked the current mode of your Magento 2 store, it’s time to finally learn how to enable developer mode in Magento 2.
Before enabling the developer mode, you need to first make sure that the object manager entities such as proxies and generated classes are clear.
If they’re not, then there might occur some unexpected errors.
And once you’ve cleared them, you need to execute the following steps to enable developer mode in Magento 2.
Step 1
First, you need to delete the generated/code as well as generated/metadata folders’ contents using the below command:
rm -rf <your Magento install dir>/generated/metadata/* <your Magento install dir>/generated/code/*
Step 2
After that, you need to set the mode that you’d like. In this case, we will set developer mode using the below command:
bin/magento deploy:mode:set developer
Once the mode is changed successfully, you’ll see the following message:
Enabled developer mode.
How to Disable Developer Mode in Magento 2?
Now, if you want to disable the developer mode and change it to production mode, you need to execute the below command.
Execute the below command to set the mode to Production in your Magento 2 store:
bin/magento deploy:mode:set production
Once you execute the above command, you’ll see messages as shown below:
Enabled maintenance mode Requested languages: en_US === frontend -> Magento/luma -> en_US === ... more ... Successful: 1884 files; errors: 0 --- === frontend -> Magento/blank -> en_US === ... more ... Successful: 1828 files; errors: 0 --- === adminhtml -> Magento/backend -> en_US === ... more ... --- === Minify templates === ... more ... Successful: 897 files modified --- New version of deployed files: 1440461332 Static content deployment complete Gathering css/styles-m.less sources. Successfully processed LESS and/or <span term-uuid="45f1f76d-91cd-4789-a8b5-1e3f321a6280" class="glossary-term" data-toggle="popover">Sass</span> files <span term-uuid="6c5cb4e9-9197-46f2-ba79-6147d9bfe66d" class="glossary-term" data-toggle="popover">CSS</span> deployment complete Generated classes: Magento\Sales\Api\Data\CreditmemoCommentInterfacePersistor Magento\Sales\Api\Data\CreditmemoCommentInterfaceFactory Magento\Sales\Api\Data\CreditmemoCommentSearchResultInterfaceFactory Magento\Sales\Api\Data\CreditmemoComment\Repository Magento\Sales\Api\Data\CreditmemoItemInterfacePersistor ... more ... Compilation complete Disabled maintenance mode Enabled production mode.
Conclusion
And that’s about it! This is the easiest and best way to enable & disable Developer Mode in Magento 2.
We hope that you found this tutorial helpful. If you have any queries, please ask them in the comments below.
And if you need our professional assistance, feel free to contact us at any time.
Recommended: How to Enable/Disable Magento 2 Maintenance Mode?