This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

Easily Debug Magento 2 Store Easily With Just Few Steps

Published on March 26, 2018 - Content Updated on

3 Min Read
Magento 2 Debug Banner

Debugging is a critical part of the development process for any ecommerce store. Professional developers understand this and prepare themselves for the task from the very start.

Some developers log the whole process and then start debugging, while others prefer debugging during the runtime – both are a great way to clean your ecommerce store off errors.

As Magento 2 is a newer version of Magento, debugging it is a little different than Magento 1. There are multiple ways to debug Magento 2 code in a store, and I will discuss how you can do it with ease to achieve the desired results.

Let’s start with the essentials first.

Magento 2 Development Modes

In Magento 2, there are three types of development modes available. These are:

  1. Default Mode
  2. Developer Mode
  3. Production Mode

To debug Magento 2 store, developers use the Magento 2 Developer Mode. This mode displays errors directly on the screen. In fact, it is a convenient way to debug even failed modules that show a blank page or 500 error on the screen. To enable the developer mode, just make the SSH connection to your server and run the following Magento 2 CLI Command on the root directory of your Magento 2 store:

php bin/magento deploy:mode:set developer

Enable PHP Display Errors to Debug Magento Store

Magento 2 has disabled the PHP display errors in the production mode for obvious security reasons. However, you can enable these display errors for debugging purpose.

To enable PHP display error reporting, open the $Magento2Root/app/bootstrap.php file and un-comment the ini_set(‘display_errors’, 1); line.

Here ‘1’ means the display_errors option is now set to ‘On.’ This will display PHP errors encountered while loading the Magento 2 store in the browser.

How to Enable Magento 2 Display Errors for Magento 2 Debug

When an error occurs, Magento 2 logs it in the var/reports file and does not display it on the screen. However, you can get it to post the error on your screen for debugging. To do so, simply enable it from $Magento2Root/pub/errors/ directory by renaming the local.xml.sample file to local.xml.

Here’s the code for local.xml.sample:

<?xml version="1.0"?>



 * Copyright © Magento, Inc. All rights reserved.

 * See COPYING.txt for license details.







            "action" can be set to "print" to show exception on screen and "email"

            to send exception on specified email




            in "subject" you can set subject of email


        <subject>Store Debug Information</subject>


            "email_address" admin email address




            "trash" is handle about trace info

            value "leave" is for store on disk

            value "delete" is for cleaning





Enable ‘Template Path Hints

The ‘Template path hints’ is a diagnostic tool that adds notation with the path on each template of Magento 2 platform. Users can enable it for the storefront and the Admin panel through the configuration menu.

To enable template path hints for debugging Magento 2 store, just login to your Magento 2 Admin panel, navigate to STORES > Configuration. On the left panel, under the ADVANCED section, click Developer. Extend Debug from the right menu and set Enabled Template Path Hints for Storefront, Enabled Template Path Hints for Admin, and Add Block Names to Hints to YES.

Save the configuration, and you will immediately notice changes on both the frontend and backend of the Magento 2 ecommerce store.

Xdebug and PhpStorm combination

The combination of Xdebug and PhpStorm is one of the best ways to debug Magento 2 store. The main advantage of this method is that it adds breakpoints to the installation process and can help the developer review and change variables at any given time.

To set up Magento 2 Xdebug, you need to configure a file in your Git repo or configure it in your environment. Next, configure PhpStorm as your IDE, and set up port forwarding.

This official Magento document provides more help on the topic of how to install and configure Xdebug with PhpStorm for debugging Magento 2 store.


The article has covered all the detials that are needed to debug Magento 2 store along with the combination of Xdebug and PhpStorm the developers life would be much easy. I believe this information is enough to get you started with debugging a Magento 2 store on your own. If you have any questions, leave them in the comments below, and I will respond as soon as I can.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Customer Review at

“Great speed, features, knowledgebase, dashboard, UX and fast, expert support. Very happy!”

Stefan [Management Consultant]

Fayyaz Khattak

Fayyaz, a passionate Motorbike tourist, works as a Team Lead — Magento Community at Cloudways - A Managed Magento Hosting Platform. His objective is to learn & share about PHP & Magento Development in Community. You can contact him at [email protected]


Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!


Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!