-
Notifications
You must be signed in to change notification settings - Fork 9
Xdebug & PHPStorm
Before all the following steps - make sure you are using the latest version of mage2click/docker-magento-mutagen by executing bin/selfupdate and bin/selfupdate -a. Check your docker-compose.yml file and remove the following lines if they exist and restart containers by bin/restart(we have had these lines generated for phpfpm section by interactive setup on previous versions):
ports: - "9001:9001"
-
First, install the Chrome Xdebug helper. After installed, right click on the Chrome icon for it and go to Options. Under IDE Key, select PHPStorm from the list and click Save.
-
Next, enable Xdebug in the PHP-FPM container by running:
bin/setup/xdebugandbin/xdebug enable. Please note that Xdebug is disabled in phpfpm container by default to prevent performance issues, so after eachbin/stop&bin/startyou will need to enable it manually viabin/xdebug enable. We also recommend to enable it only before debugging, since it has an impact to TTFB when enabled and not used. -
Open
PHPStorm > Preferences > Languages & Frameworks > PHP > Debugand set Debug Port to9001. -
Open
PHPStorm > Preferences > Languages & Frameworks > PHP > Serversand create a new server:- Set Name and Host to your domain name (ex.
magento2.test) - Keep port set to
80 - Check the Path Mappings box and map
srcto the absolute path of/var/www/html
- Set Name and Host to your domain name (ex.
-
Go to
Run > Edit Configurationsand create a newPHP Remote Debugconfiguration by clicking the plus sign and selecting it. Set the Name to your domain (ex.magento2.test). Check theFilter debug connection by IDE keycheckbox, select the server you just setup, and under IDE Key enterPHPSTORM. This IDE Key should match the IDE Key set by the Chrome Xdebug Helper. Then click OK to finish setting up the remote debugger in PHPStorm. -
Open up
src/pub/index.php, and set a breakpoint near the end of the file. Go toRun > Debug 'magento2.test', and open up a web browser. Ensure the Chrome Xdebug helper is enabled by clicking on it > Debug. Navigate to your Magento store URL, and Xdebug within PHPStorm should now trigger the debugger and pause at the toggled breakpoint.
- Add breakpoint in your php file in PHPStorm
- Run
bin/bashto login to php container - Run the needed php script with the following prefix:
XDEBUG_CONFIG="remote_enable=1 remote_port=9001 remote_host=host.docker.internal idekey=PHPSTORM" /usr/local/bin/php -f <path_to_php_script/php_script_name.php>for example to debug thebin/magentoscript use the folowing commandXDEBUG_CONFIG="remote_enable=1 remote_port=9001 remote_host=host.docker.internal idekey=PHPSTORM" /usr/local/bin/php -f bin/magento
Feel free to contact us via in case you need help with configs.
Copyright (c) 2019 Mage2click