I have troubles with setting up debugging php cli application. I work on Mac OS and I have here Vagrant with Ubuntu inside, and inside this Ubuntu I have docker. So one of the docker containers runs my php application, where the PHP interpreter lives.
Before (when the application was exactly in Vagrant machine) I was using this command to debug my cli applications, but now it does not work.:
export XDEBUG_CONFIG="remote_enable=1 remote_mode=req remote_port=9000 remote_host=192.168.10.10 remote_connect_back=0"
How can I set up PhpStorm to debug my php cli app ?
Inside of your Docker container don't use remote_host. Also, you don't have to expose any additional ports in Docker or in Vagrant.
Here is my xdebug.ini file that works with PHP 5.6
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_connect_back=1
Make sure that PhpStorm (2016.1 in my case) is configured correctly
Once this is done find Listen for debugger connections icon in PhpStorm in the toolbar and click it.
If you want to call it from a command line remember to include XDEBUG_SESSION cookie, i.e.
curl 'http://localhost' -sSLI -H 'Cookie: XDEBUG_SESSION=xdebug'
If you use Firefox install The easiest Xdebug and enable it in the toolbar.
In my case, debugging through web browsers worked well, the problmes came with CLI debugging (phpunit). This is because xdebug get lost with path mappings and you need to explicit tell docker.
You need to tell Docker which server configuration in PHPStorm should use, just export that env variable inside your docker container.
export PHP_IDE_CONFIG="serverName=<server-name>"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With