...
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 in a dedicated terminalconnect on your local workstation in another shell.
Connect your Xdebug client to the debugger:
debug-proxy:
localhost:9001
client-listen-port: use the random randomly chosen port printed by
the xdebug-helper-command
IDE-Key: use one of the keys printed by the helper-command
(xdebug-helper
. Every role gets its own IDE-Key to allow full control of the debugging process.)
Simple
...
example with one role
On
...
bastion host
Code Block | ||
---|---|---|
| ||
$ 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: <idekey<ide-key-role1>, <idekey<ide-key-role2> $ |
On
...
local workstation
connect Connect using SSH with , specifying client-listen-ports
Code Block language bash $ ssh -A -R 20184:localhost:20184 -L 9001:localhost:9001 <bastion-host>
In another set of shells , you can use dbgpClient for debugging to debug each role:
Code Block language bash $ curl -LO https://xdebug.org/files/binaries/dbgpClient $ chmod +x dbgpClient # register client with first role $ ./dbgpClient -f -r '<idekey<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 (exiting exit the client using Ctrl
+C
), you need to unregister deregister the idekey IDE-key from the proxy for future usage. Otherwise, it will be remain blocked.:
Code Block | ||
---|---|---|
| ||
$ ./dbgpClient -f -u '<idekey<ide-key-role>' -y localhost:9001 |
Advanded Example with two roles
On
...
bastion host
Code Block | ||
---|---|---|
| ||
$ 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 $ |
On
...
local workstation
connect Connect using SSH with specifying 2 two client-listen-ports (you can choose any port you like, e.g. 20184 and 20185 in this example):
Code Block language bash $ 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 for debugging to debug each role:
connect to role ‘backend’
backend
:
Code Block language bash $ 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’
frontend
:
Code Block # 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 (exiting exit the client using Ctrl
+C
), you need to unregister deregister the idekey IDE-key from the proxy for future usage. Otherwise, it will be blocked.
...
Screencast using PhpStorm (Simple Example)
Click here to view/download We have prepared a PhpStorm screencast illustrating how to set up xdebug (download).