Debugging with Xdebug - mage2click/m2c GitHub Wiki
Mage2click toolset supports Magento debugging with Xdebug out of the box. Only a few configuration steps are required.
In this configuration example, we're covering the PHPStorm IDE.
Configuration
Open Servers preferences section.
Preferences | Languages & Frameworks | PHP | Servers
Add the new server to match your project and configure path mappings. Your project directory must be mapped to /var/www/html
path. Don't forget to press Apply
or OK
button. Check the screenshot below as reference.
images/debugging-with-xdebug/m2c-xdebug-configuration-servers.png
After that, go to the PHP preferences section.
Preferences | Languages & Frameworks | PHP
Select PHP language level to match PHP version used in your Magento project.
For CLI Interpreter, click on three dots to add a new one. A new CLI Interpreters dialog box will appear, press on plus (+) sign and choose From Docker, Vagrant, VM, Remote...
images/debugging-with-xdebug/m2c-xdebug-configuration-cli-interpreters.png
In the appeared dialog box, select Docker
and for Image name choose mage2click xdebug Docker image with corresponding PHP version to your Magento project, for example mage2click/m2c:php-fpm-7.2-xdebug-alpine
. Press OK
.
images/debugging-with-xdebug/m2c-xdebug-configuration-remote-php-interpreter.png
Also, press OK
on CLI Interpreters dialogue box.
images/debugging-with-xdebug/m2c-xdebug-configuration-cli-interpreters-ok.png
Make sure that newly created CLI Interpreter is selected and press OK
on PHP preferences section.
images/debugging-with-xdebug/m2c-xdebug-configuration-php-preferences.png
Usage
To start/stop debugging, press Start/Stop Listening for PHP Debug Connections
button.
images/debugging-with-xdebug/m2c-xdebug-configuration-start-stop-debugging.png
On the browser side, you will need to set XDEBUG_SESSION
cookie to activate Xdebug or simply use Xdebug Helper browser extension for that.
IMPORTANT! Be aware that when you have activated debugging in the browser or have set XDEBUG_SESSION
cookie value, Xdebug remains active even if you are not activating debugging at IDE side! For best performance, deactivate debugging in the browser or unset XDEBUG_SESSION
cookie value when you are not debugging.
images/debugging-with-xdebug/m2c-xdebug-configuration-browser.png