Setting XDebug breakpoints for remote CLI scripts with PHPStorm

14th Nov, 2013 | php phpstorm xdebug

PHPStorm makes setting and using XDebug breakpoints easy. Just define the server configurations and click the phone icon to listen mode and load your site in a browser. With the correct xdebug.ini parameters it works if your application is either running on the same machine as PHPStorm or on a remote server.

Running CLI scripts on a different server to the machine PHPStorm is running on require a bit more effort though.

First ensure the phone icon is active so PHP Storm is listening for connections.

Again ensure server configurations are setup for your project. There will be a server name and configuration name.

On the remote server define the server name that PHPStorm should listen for:

export PHP_IDE_CONFIG="serverName=mbp.uko4.com"

Now execute the CLI script on the remote machine.

If the server name you specify matches the server name you have defined in your project execution will halt on your breakpoints.

Or will it?

For me this works fine for some environments. When this is not enough export some more:

export XDEBUG_CONFIG="idekey=PHPSTORM"

to get it going and

unset XDEBUG_CONFIG

to stop it. Nice!