Xdebug Phpstorm Cli
There is no clash between xdebug port and php-fpm. The port is the one that the xdebug client (PhpStorm, in this case) will use to listen, and since the client and php-fpm are not running on the same machine (php-fpm runs within a container, the client on the container host), they never clash. Instruct XDebug to connect back to the IP where web request came from. Instruct XDebug to connect to host.docker.internal for command line execution or whenever “connect back” is not possible. Set PHPIDECONFIG env variable to serverName=localhost. This will tell your PhpStorm which server configuration to use. See next step for details.
In host:
Phpstorm Setup Xdebug
Configure phpstorm: In Settings Languages & Frameworks PHP Servers create a new entry. Give it a name (e.g. Localhost) and set the Host to 'localhost' (needs to match the serverName defined in your PHPIDECONFIG environment variable. Set the port to 80 and choose Xdebug as a debugger. Currently PhpStorm supports two debug extensions, namely Xdebug and Zend Debugger. Before start debugging command line scripts you need to configure your development environment: the PHP interpreter and PhpStorm. We keep the other default parameters to keep the configuration as minimal as possible. So, with this setup, the port used by Xdebug is 9000 and the default IP address is 127.0.0.1. Check out the xdebug.remotehost and xdebug.remoteport parameters in the documentation. Now, let's check the configuration inside PHPStorm.
Phpstorm Xdebug Not Working
- Go to PHPStorm
Settings > Project settings > PHP > Servers
- Add server with following parameters:
- Name:
vagrant
(same asserverName=
indebug
script) - Host, port: set vagrant box IP and port
- Debugger: Xdebug
- [v] Use path mappings
- Map your project root in host to relative dir in guest
- Hit OK
- Name:
- PHPStorm > Run > Start listen for PHP Debug connections
- Put a breakpoint
In guest:
- Find where your Xdebug config is stored. Run
$ php -i | grep ini
and look for*xdebug.ini
or*custom.ini
- depends on configuration (mine was in/etc/php5/cli/conf.d/zzzz_custom.ini
) - Add following
xdebug.remote_host = 11.22.33.1
, when box ip is11.22.33.*
- Create file
/usr/bin/debug
with contents added below (filedebug
below) - Make it executable
$ sudo chmod 0777 /usr/bin/debug
- Run your script prefixed with
debug
:$ debug app/console cache:clear
- Debugger window should open in IDE