You have tried to access an archived page. Please go to the new https://root360.atlassian.net/wiki/spaces/KB to find more documents. |
Using Xdebug for PHP allows developers to debug PHP-processes by connecting interactively.
This allows setting breakpoints, changing content and reviewing stack traces.
We support the usage of xdebug by installing and configuring the required packages on the application instances that use PHP.
To allow remote debugging we install an Xdebug proxy on the bastion host of your environment.
To enable Xdebug for PHP please contact our root360 customer service.
When Xdebug is activated, you can connect to your Xdebug sessions by following these steps:
On your bastion host, start the program xdebug-helper
. This will start an xdebug proxy in the background and print out connection information.
Run the printed SSH-command on your local workstation in another shell.
Connect your Xdebug client to the debugger:
debug-proxy: localhost:9001
client-listen-port: use the randomly chosen port printed by xdebug-helper
IDE-Key: use one of the keys printed by xdebug-helper
. Every role gets its own IDE-Key to allow full control of the debugging process.
$ xdebug-helper Starting xdebug proxy session (lasts 24h) ... Access logs by running 'screen -r xdebug-proxy' (leave with <ctrl>+<a>+<d>) Client-Listen-Port: 20184 Debug-Proxy: localhost:9001 SSH-Command: ssh -A -R 20184:localhost:20184 -L 9001:localhost:9001 <bastion-host> Available IDE-Keys: <ide-key-role1>, <ide-key-role2> $ |
Connect using SSH, specifying client-listen-ports
$ ssh -A -R 20184:localhost:20184 -L 9001:localhost:9001 <bastion-host> |
In another set of shells you can use dbgpClient to debug each role:
$ curl -LO https://xdebug.org/files/binaries/dbgpClient $ chmod +x dbgpClient # register client with first role $ ./dbgpClient -f -r '<ide-key-role>' -y localhost:9001 -p 20184 proxyinit | success Xdebug Simple DBGp client (0.2)Copyright 2019-2020 by Derick Rethans Waiting for debug server to connect on port 20184. |
Now you can start debugging (see Help for commands).
When your debugging session is done (exit the client using Ctrl
+C
), you need to deregister the IDE-key from the proxy for future usage. Otherwise, it will remain blocked:
$ ./dbgpClient -f -u '<ide-key-role>' -y localhost:9001 |
$ xdebug-helper Starting xdebug proxy session (lasts 24h) ... Access logs by running 'screen -r xdebug-proxy' (leave with <ctrl>+<a>+<d>) Client-Listen-Port: 20184 Debug-Proxy: localhost:9001 SSH-Command: ssh -A -R 20184:localhost:20184 -L 9001:localhost:9001 <bastion-host> Available IDE-Keys: xdebug-fpm-web, xdebug-fpm-backend, xdebug-fpm-frontend $ |
Connect using SSH specifying two client-listen-ports (you can choose any port you like, e.g. 20184 and 20185 in this example):
$ ssh -A -R 20184:localhost:20184 -R 20185:localhost:20185 -L 9001:localhost:9001 <bastion-host> |
In another set of shells, you can use dbgpClient to debug each role:
connect to role backend
:
$ curl -LO https://xdebug.org/files/binaries/dbgpClient $ chmod +x dbgpClient # register client with first role $ ./dbgpClient -f -r 'debug-backend' -y localhost:9001 -p 20184 proxyinit | success Xdebug Simple DBGp client (0.2)Copyright 2019-2020 by Derick Rethans Waiting for debug server to connect on port 20184. |
connect to role frontend
:
# register client with second role $ ./dbgpClient -f -r 'debug-frontend' -y localhost:9001 -p 20185 proxyinit | success Xdebug Simple DBGp client (0.2)Copyright 2019-2020 by Derick Rethans Waiting for debug server to connect on port 20185. |
Now you can start debugging (see Help for commands). When your debugging session is done (exit the client using Ctrl
+C
), you need to deregister the IDE-key from the proxy for future usage. Otherwise, it will be blocked.
$ ./dbgpClient -f -u 'xdebug-backend' -y localhost:9001 $ ./dbgpClient -f -u 'xdebug-frontend' -y localhost:9001 |
We have prepared a PhpStorm screencast illustrating how to set up xdebug (download).