Hi.
CLI debugging. I never did that. Until today. My tests started to fail and I had no idea why.
So that’s my story why I started to debug tests in the CLI via SSH.
Here’s a list of ingredients:
- PhpStorm,
- remote SSH (I’m using Vagrant),
- PHP + XDebug.
First thing what we need to do is to configure the PhpStorm.
Open your setting and go toĀ Languages & Frameworks >Ā PHP >Ā Debug >Ā DBGp Proxy.
- Fill the fieldĀ IDE key with key you choose (I choseĀ PHPSTORM and I recommend it).
- In theĀ Host field put the IP which is seen by remote (run echoĀ $SSH_CLIENT on the remoteĀ to see it).
- DefaultĀ PortĀ is 9000 and you should not change it.
Next thing to configure isĀ Language & Frameworks >Ā PHP >Ā Servers.
- Put the serverĀ Name.
- In theĀ Host field type the IP address, same as on DBGp Proxy.
- If you set other Port forĀ DBGp Proxy then change it here.
- As we are working onĀ XDebug you don’t have to change the Debugger :).
- My remote has different folders structure so I had to set path mapping, probably you will have to do the same.
Ok PhpStorm is ready to go.
Now go toĀ SSH and run this command:
export PHP_IDE_CONFIG="serverName=VAGRANT" export XDEBUG_CONFIG="remote_host=10.0.2.2 idekey=PHPSTORM remote_connect_back=0"
In the first line put yourĀ ServerĀ Name which you’ve just set. In the second just update the remote_host with theĀ IP address and change theĀ idekey to yours.
The last thing to do is to enable listening for debug connections in theĀ PhpStorm. Just click the button in the top right corner:
Ah I forgot, please add someĀ breakpoints! And then you can run your tests / scripts etc.
Enjoy š



