How to debug in Magento 2

0
289

1. Use the developer mode:

Developer mode: In this mode, static files are not cached, and system errors and exceptions are displayed to users. In this mode, there is no need to manage the external Internet traffic.

The developer mode is intended to be used and useful during development.
Here is 4 ways to change Magento 2 to developer mode:

  • Command line:
php bin/magento deploy:mode:set developer
  • Config file app/etc/env.php

Find line:

'MAGE_MODE' => 'default'

Change to:

'MAGE_MODE' => 'developer'
  • Virtual Host

apache2:

SetEnv MAGE_MODE developer

nginx

set $MAGE_MODE developer;
  • Use .htaccess

you can go to .htaccess file and un-comment the developer command:

Changes mode magento 2

2. Display Magento error notifications:

Enable magento error notifications, please go to  pub/errors and rename local.xml.sample -> local.xml

enable_error_notifi_magento2

3.Enable php display errors:

Open file : app/bootstrap.php -> un-comment the line ini_set:

enable php display error

4. Enable template hints:

Go to admin panel:

For Front End:

theme debug magento 2

Store > Configuration > Advanced > Developer > Debug > Enabled Template Path Hints for Storefront > Yes

For Admin :

Store > Configuration > Advanced > Developer > Debug > Enabled
Template Path Hints for Admin > Yes

Enablet path hint magento 2