Search code examples
phpdockerphpstormxdebug

Docker+php-fpm+Xdebug (on Linux) + PhpStorm (on Windows)


I have Docker installed on my Linux host and raised a container with php-fpm and Xdebug. PhpStorm is installed on Windows server. The project is hoisted through gitlab. Can you please tell me how to set up debugging via Xdebug in such a bundle?

Docker ver.

Client: Docker Engine - Community
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46d9d
 Built:             Wed Sep 16 17:03:45 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       4484c46d9d
  Built:            Wed Sep 16 17:02:21 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.7
  GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Xdebug ver. 2.9.8

I need to do a setup without DBGp Proxy. It needs to be configured using path mappings. Is this possible?

Linux and Windows servers are on the same subnet, but I still get timeout in Xdebug logs when I open the page.

UPD. Xdebug log

[79] Log opened at 2021-04-08 06:51:34
[79] I: Checking remote connect back address.
[79] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[79] I: Checking header 'REMOTE_ADDR'.
[79] I: Remote address found, connecting to xx.xx.xx.xx:9000.
[79] E: Time-out connecting to client (Waited: 200 ms). :-(
[79] Log closed at 2021-04-08 06:51:34

I also decided to use DBGP Proxy, but there are also some problems with it. Tried proxy for both Windows and Linux.

[14688] Log opened at 2021-04-08 06:55:25
[14688] I: Checking remote connect back address.
[14688] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[14688] I: Checking header 'REMOTE_ADDR'.
[14688] I: Remote address found, connecting to xx.xx.xx.xx:9000.
[14688] I: Connected to client. :-)
[14688] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/debug.php" language="PHP" xdebug:language_version="7.3.22" protocol_version="1.0" appid="14688" idekey="OR"><engine version="2.9.8"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

[78] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

[78] Log closed at 2021-04-08 06:56:11

But it didn't work through browser and Postman. And only the request in the terminal via curl hangs, and the proxy on Linux issued the following

Xdebug Simple DBGp client (0.4.2)
Copyright 2019-2020 by Derick Rethans
In dumb client mode

Waiting for debug server to connect on port 9000.
Connect from 192.168.112.4:45638
DBGp/1.0: Xdebug 2.9.8 — For PHP 7.3.22
Debugging file:///var/www/html/debug.php (ID: 78/OR)

Solution

  • Thanks to all. The problem turned out to be in the firewall. I opened port 9000 and it worked