Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. On your bastion host, start the program xdebug-helper.
    This will start an xdebug proxy in the background and print out connection information.

  2. Run the printed SSH-command in a dedicated terminalconnect on your local workstation in another shell.

  3. 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
languagebash
$ 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

  1. connect Connect using SSH with , specifying client-listen-ports

    Code Block
    languagebash
    $ ssh -A -R 20184:localhost:20184 -L 9001:localhost:9001 <bastion-host>
  2. In another set of shells , you can use dbgpClient for debugging to debug each role:

    Code Block
    languagebash
    $ 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
languagebash
$ ./dbgpClient -f -u '<idekey<ide-key-role>' -y localhost:9001

Advanded Example with two roles

On

...

bastion host

Code Block
languagebash
$ 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

  1. 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
    languagebash
    $ ssh -A -R 20184:localhost:20184 -R 20185:localhost:20185 -L 9001:localhost:9001 <bastion-host>
  2. In another set of shells, you can use dbgpClient for debugging to debug each role:

    • connect to role ‘backend’ backend:

    Code Block
    languagebash
    $ 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).