To setup debugger for php bin/magento cli

1. make sure your xdebug is configured to accept external connection in storm
2. run any M2 cli command and when prompted click accept on the external connection dialog
3. click Run > Edit Configurations
4. setup a new ‘PHP Remote Debug’ configuration as the uploaded image, take a note on server, it’s the vagrant IP, and set ‘IDE key session’ as phpstorm

PHPStorm Magento2 CLI Debug
5. setup a breakpoint on InstallSchema.php or InstallData.php etc
6. map your class path from Preference > Language & Frameworks > PHP > Servers, you need to select the host with the IP i.e. 10.0.2.15
7. click on the ‘BUG’ icon on your storm at the right top corner and run in terminal
XDEBUG_CONFIG=idekey=phpstorm php bin/magento setup:upgrade

Categorized in: