Debugging in Magento 2
2 min readJul 21, 2023
One of the best way to debug Magento 2 store is xdebug. Using xdebugger developer can add breakpoints to review any line of code and update variable at any given time.
To setup debugger in PHPStorm follow the below steps.
Install xdebug respective to your installed PHP version
sudo apt install php7.x-xdebug
Confirm installation
php –version
Open and edit xdebug.ini file and add below line of codes
sudo vi /etc/php/7.x/mods-available/xdebug.ini (Confirm this path
according to your computer)
Copy and paste below lines in xdebug.ini
xdebug.remote_enable = 1
xdebug.remote_port = 9898
xdebug.idekey = “PHPSTORM”
xdebug.show_error_trace = 1
xdebug.remote_autostart = 0
In PHPStorm navigate to File → Settings → Language & Frameworks → PHP → Debug → Xdebug → Debug Port → 9898 → apply → ok
In PHPStorm navigate to File → Settings → Language & Frameworks → PHP
Set PHP language level and CLI Interpreter
Restart apache to reflect changes
sudo service apache2 restart