Reading list Switch to dark mode

    Magento 2 Production Mode vs Developer Mode

    Updated 22 May 2023

    The main difference between the Magento 1 and Magento 2 platforms is the introduction of development mode. With the release of Magento 2, modes are introduced that reflect different configurations of the Magento codebase and affect website operation and performance.

    Magento 2 added three different modes.
    Default, Developer, Production.

    These modes serve different purposes and provide different features to support the development and deployment of Magento 2 applications. Here’s an overview of Magento 2’s production and developer modes:

    Magento 2 Default Mode

    The default mode of Magento 2 is how Magento 2 behaves when no other mode is specified, such as when installing on a single server for the first time. It is not optimized for production use as it is intended to make Magento 2 easy to use without any additional configuration.

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    • Errors and exceptions are never displayed to the user. These are logged in the var/reports directory on the server.
    • In this mode, Magento dynamically generates static content such as images and static files instead of serving them from cache, and symbolic links to static files are published to the pub/static.
    • It provides a balance between performance and debugging capabilities.

    Magento 2 Developer Mode

    Magento 2 developer mode is a configuration intended for development and debugging purposes. Here are the key features and benefits of running Magento 2 in developer mode:

    • Developer mode in Magento 2 is great for development tasks like debugging errors and installing Magento 2 extensions. In this mode, static view files are not cached on the file system. Instead, they are generated on demand and written to the pub/static folder.
      On-the-Fly View Files Regeneration: Unlike production mode, developer mode regenerates static view files (CSS, JavaScript, etc.) on the fly. This allows developers to see their changes immediately without needing to manually regenerate the files.
    • Detailed exceptions and errors messages are displayed in the browser: Developer mode displays detailed error messages and stack traces, making it easier to identify and troubleshoot issues during development. This helps developers quickly identify and fix errors in their code.
    • Developer mode generates detailed logs in the var/report folder, throws errors in the frontend, and throws exceptions in the error handler instead of in the log file. This allows you to troubleshoot and debug extension conflicts without looking through log files.
    • Additional Logging and Debugging Tools: Developer mode enables enhanced logging and debugging capabilities. Developers have access to detailed logs, performance profiling, and other developer-oriented tools to diagnose and troubleshoot issues efficiently.
    • After enabling developer mode, admin can access “Developer” section in Magento admin panel, the admin will navigate through Stores > Settings > Configuration > Advanced > Developer. This section includes advanced configuration options for developers as shown in below image:
    dev-sec

    Magento 2 Production Mode

    Production mode is designed for deployment to production systems. Every live site should have a production mode because production mode uses full page caching of web pages to ensure smooth and efficient working of site. Below are the key features and benefits of running Magento 2 in production mode:

    • Static files are stored in cache: Static files are writes to the pub/static directory in the project root and serves them from cache. This mode utilizes full page caching along with a fully built pub folder for retrieval and is optimized for smooth and efficient operations resulting in the best customer experience.
    • Error messages are minimal and not displayed to the end users to avoid exposing sensitive information.
    • Also, from a security point of view, production mode is the most secure as no symlinks are created for the pub/static folder. When an unauthenticated user accesses Pub/Static to modify data, only duplicate versions of these files are overwritten with the next static post.

    Overall, running Magento 2 in production mode is crucial for achieving optimal performance, stability, and security for your live website.

    Display the current mode

    You have to run the below command on the Magento 2 root directory to check the current mode

    php bin/magento deploy:mode:show

    To change the magento 2 mode

    php bin/magento deploy:mode:set {mode}

    Where {mode} is required; it can be either defaultdeveloper, or production

    Hope this will be helpful.

    Thanks 🙂

    . . .

    Leave a Comment

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


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home