[PHP] Debugging remote machines with multiple people without touching the company router [Xdebug×DBGpProxy]

Aug 27, 2020 PHP PhpStorm xdebug DBGpProxy


We aim to enable multiple developers to use a debugger (breakpoint) for a PHP web application (nginx + php-fpm) running on one server. Since it is a company, it is conditional that you cannot tamper with the router.

The article title is [PHP] Debugging remote machines “with multiple people” [Xdebug x DBGpProxy] It is a pakuri of.




・Local machine: Mac ・Remote machine: Linux ・IDE: PHPStorm (2020.2) ・Browser: Chrome ・Ssh connection to the server (for remote port forwarding) ・Environment where it is not easy to set port forwarding settings for routers such as offices

*I think that you can do not limited to these, but I will proceed with this premise as an article

Server settings


PHP extension, standard as a debugger. I have omitted the introduction because there are other commentary articles.

Xdebug settings

Enable remote debugging and make it talk to port 9001 on localhost (localhost is pointing to the server as it is running on the server).


DBGp Proxy

DBGp Proxy is what

Proxy that relays communication contents from Xdebug. You can register a key and switch the relay destination according to the key value. The key is called the IDE Key. ~~ Did I have to bother with an IDE on my head~~


From the following


Start DBGp Proxy

When starting DBGp Proxy, it is necessary to specify the communication port from Xdebug and the port for IDE Key registration. The former is called server and the latter is called client. Xdebug configures localhost to communicate with port:9001, so the server will listen on port:9001 accordingly. For client, specify port:9002 (of course, other is OK).

chmod +x dbgpProxy
./dbgpProxy --client localhost:9002 --server localhost:9001

Local settings

Make sure that the same PHP file exists on the server locally

Make sure the php file on the server is also local. It assumes a development style of editing locally and uploading to the server. * Can you do remote development with PhpStorm? I’m not familiar

Register IDE Key to DBGp Proxy

Register the IDE Key alice on port 9003 (it doesn’t matter if it is not covered by multiple people, but here we will register it with the name of the developer). You can register the IDE Key with DBGp Proxy with the proxyinit command.

echo -en "proxyinit -p 9003 -k alice -m 1\0" | nc localhost 9002

(A null character is required at the end, so specify \0 in the -e option of echo.)

PhpStorm Debugger Settings

Set Xdebug to Listen on localhost:9003. Enter the Debug port under Preferences>Language&Frameworks>PHP>Debug. image.png

Press the Start Listening for PHP Debug Connections button in the upper right corner of PhpStorm image.png

Now you can wait for Xdebug to come to localhost:9003.

Introducing Xdebug helper

Xdebug helper is what

Chrome extension. Used to put the value of XDEBUG_SESSION in the cookie


Just add chrome extension

Xdebug helper


You can specify the IDE key from the options of Xdebug helper. Set the selection field to Other and the value to alice.


Path mapping (server and local)

Settings (PhpStorm)

Register the path mapping from Preferences>Language&Frameworks>PHP>Servers. Specify the values of File/Directory and Absolute path on the server so that the files on the server and the local files have the same structure.


You can actually put a breakpoint in PhpStorm and go where it stops.

Remote port forwarding

is what

You can connect the output to a specific port on the server to the input to a specific local port. It is necessary to set Gateway Ports with sshd_config.

GatewayPorts yes


ssh -N -R 9003:localhost:9003 remote server

You will now be able to receive the output on port 9003 locally on the server.

Paste breakpoint and execute on PhpStorm

Click on the left side of the code. A red circle is a breakpoint image.png

Access it in your browser so that the code with the breakpoint is executed. If the debugger on the PHPStorm side starts, it is happy!



Multiuser debugging via Xdebug proxies

Remote debugging via SSH tunnel-official help | PhpStorm

Zero Configuration Debug-Official Help | PhpStorm

[PHP] Do you understand remote debugging of Xdebug? -Qiita

[PHP] Debugging remote machines “with multiple people” [Xdebug×DBGpProxy]-Qiita

Xdebug Documentation

DBGp Proxy Tool