Magento 2 is a popular e-commerce platform. Developer Mode is a special mode that helps developers debug and test their websites. It shows detailed error messages and logs, making it easier to find and fix issues. Sometimes you may need to enable or disable Developer Mode in Magento 2. Here are two easy methods to do it.
Method 1: Changing Mode via SSH/CLI
This is the quick and suggest way to enable or disable developer mode on Magento2 application.
Enable Developer Mode:
- Login to the system, where Magento 2 application is configured.
- Navigate to Your Magento 2 Directory:
cd /path/to/your/magento2
- To enable the developer mode, type:
php bin/magento deploy:mode:set developer
- You should see a message saying Developer Mode is enabled.
Disable Developer Mode:
cd /path/to/your/magento2
php bin/magento deploy:mode:set developer
To disable the developer mode, simple type:
php bin/magento deploy:mode:set production
You should see a message saying Developer Mode is disabled.
Method 2: Changing Developer Mode via .htaccess
Instead of making changes in configuration, You can also enable Magento2 developer mode using .htaccess file. But tis will work only if application is configures with Apache web server.
Enable Developer Mode:
- Find and edit the .htaccess file in your Magento 2 root directory.
- Add this line at the top of the file:
SetEnv MAGE_MODE developer
- Save the file.
Disable Developer Mode:
- Remove the line SetEnv MAGE_MODE developer or change developer to production.
SetEnv MAGE_MODE production
- Save the file.
Wrap Up
Enabling or disabling Developer Mode in Magento 2 is simple. You can use SSH/CLI or edit the .htaccess file. Remember, you should not enable Developer Mode on a live, production website because it shows detailed error messages and logs that can slow down your site and expose sensitive information. Use Developer Mode only for testing and debugging during development.