Skip to content
Home » News » Magento 2 Modes: Default, Developer, and Production

Magento 2 Modes: Default, Developer, and Production

Magento 2 offers three different modes to help manage your store’s performance and functionality. These modes are designed for different stages of store development and operation: Default Mode, Developer Mode, and Production Mode. Understanding and switching between these modes is essential for optimizing your store.

What Are Magento 2 Modes?

Magento 2 modes define how the store operates in different environments:

  • Default Mode is the standard mode after installation and is suitable for initial setup. It combines elements of both developer and production environments but is not optimized for live performance.
  • Developer Mode is ideal for debugging and customization. It provides detailed error reporting and allows developers to test and modify the store efficiently.
  • Production Mode is optimized for live stores, offering improved performance, caching, and security. It ensures a smooth shopping experience for customers.

Each mode serves a unique purpose and is used for store operations at different stages.

How to Check the Current Magento 2 Mode

To see which mode your Magento 2 store is currently in, run the following command:

bin/magento deploy:mode:show

This will display a message like:

Current application mode: [mode]

where [mode] will indicate default, developer, or production.

bin/magento deploy:mode:show command in CLI

Switching Magento 2 Modes

To change the mode, use the command:

bin/magento deploy:mode:set [mode]

Replace [mode] with default, developer, or production. Here’s how you switch to each mode:

bin/magento deploy:mode:set default
bin/magento deploy:mode:set developer
bin/magento deploy:mode:set production

For Developer Mode, you may need to clear some directories before switching:

rm -rf /generated/metadata/* /generated/code/*

Then, enable Developer Mode:

bin/magento deploy:mode:set developer

Magento 2 Default Mode

Magento 2 Default Mode is the mode that is active immediately after installation. This mode allows the store to function without additional configuration, making it suitable for initial setup and exploration. In Default Mode, Magento dynamically generates static files such as images and CSS, then caches them. This process can slow down page loading because the files are generated on the fly. Unlike Developer Mode, errors are not displayed on the screen but are instead stored in log files located in the magento2_folder/var/log directory. Since it lacks the full speed optimizations of Production Mode and the debugging capabilities of Developer Mode, Default Mode is not recommended for long-term use. However, it is useful for those who are just starting to familiarize themselves with Magento 2.

To enable Default Mode, run the following command:

bin/magento deploy:mode:set default
bin/magento deploy:mode:set default command in CLI (Magento 2 modes)

Magento 2 Developer Mode

Magento 2 Developer Mode is designed specifically for developers who need to debug and customize their store. This mode provides detailed error reporting by displaying errors directly on the screen instead of logging them. It does not cache static files, which means they are regenerated every time they are needed and stored in the pub/static directory. This makes debugging easier but slows down the overall performance of the store. Developer Mode also compiles code automatically and allows for advanced code debugging, making it essential for developers working on new features or customizations.

To enable Developer Mode, use the following command:

bin/magento deploy:mode:set developer
bin/magento deploy:mode:set developer command in CLI (Magento 2 modes)

If you experience CSS loading issues in Developer Mode, you may need to update the app/etc/di.xml file. Locate the developerMaterialization section and change Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink to Magento\Framework\App\View\Asset\MaterializationStrategy\Copy. Additionally, delete the files in the pub/static directory, being careful not to remove the .htaccess file.

Magento 2 Production Mode

Magento 2 Production Mode is the mode used for live stores to ensure the best performance, stability, and security. In this mode, all static view files are pre-compiled and cached to improve site speed. Unlike Developer Mode, Production Mode does not display error messages on the screen; instead, errors are logged for security reasons. This mode also prevents accidental changes to the system and disables certain admin settings that could negatively impact the store’s performance. Since all necessary files are generated in advance, Production Mode offers the fastest loading times and the most optimized experience for customers.

To enable Production Mode, use the following command:

bin/magento deploy:mode:set production
bin/magento deploy:mode:set production command in CLI (Magento 2 modes)

Conclusion

Each mode serves a specific purpose. Default Mode is for basic setup, Developer Mode is for coding and debugging, and Production Mode is for live performance. Knowing when and how to switch Magento 2 modes will help you manage your store effectively and avoid unnecessary slowdowns or errors. By using the right mode at the right time, you can ensure your store runs smoothly and efficiently.

Author

Leave a Reply

Your email address will not be published. Required fields are marked *