0

I have been trying to connect Xdebug to my open server project for the 2nd day, but it refuses to work. I've read a lot of articles and tried all the different options but still couldn't get the breakpoint to hit. Below I will send all the parameters that I have, I will be endlessly grateful if you can help me solve my problem.

Information from php_info (): enter image description here

Extension for VSCode: enter image description here

php.ini info:

zend_extension="C:/openserver/modules/php/PHP_8.0/ext/php_xdebug.dll"
xdebug.mode = develop,debug
xdebug.client_host = "localhost"
xdebug.client_port = 9003
xdebug.idekey = "VSCODE"

launch.json info:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 0,
            "runtimeArgs": [
                "-dxdebug.start_with_request=yes"
            ],
            "env": {
                "XDEBUG_MODE": "debug,develop",
                "XDEBUG_CONFIG": "client_port=${port}"
            }
        },
        {
            "name": "Launch Built-in web server",
            "type": "php",
            "request": "launch",
            "runtimeArgs": [
                "-dxdebug.mode=debug",
                "-dxdebug.start_with_request=yes",
                "-S",
                "localhost:0"
            ],
            "program": "",
            "cwd": "${workspaceRoot}",
            "port": 9000,
            "serverReadyAction": {
                "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
                "uriFormat": "http://localhost:%s",
                "action": "openExternally"
            }
        }
    ]
}

Also, following the advice from some articles, I installed the Xdebug helper in my Firefox.

netstat -abno:

PS C:\openserver\domains\coolphp> netstat -abno

Активные подключения

  Имя    Локальный адрес        Внешний адрес          Состояние       PID
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       980
  RpcEptMapper
 [svchost.exe]
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
 Не удается получить сведения о владельце
  TCP    0.0.0.0:5040           0.0.0.0:0              LISTENING       4656
  CDPSvc
 [svchost.exe]
  TCP    0.0.0.0:5357           0.0.0.0:0              LISTENING       4
 Не удается получить сведения о владельце
  TCP    0.0.0.0:7680           0.0.0.0:0              LISTENING       10452
 Не удается получить сведения о владельце
  TCP    0.0.0.0:8733           0.0.0.0:0              LISTENING       4
 Не удается получить сведения о владельце
  TCP    0.0.0.0:49664          0.0.0.0:0              LISTENING       924
 [lsass.exe]
  TCP    0.0.0.0:49665          0.0.0.0:0              LISTENING       800
 Не удается получить сведения о владельце
  TCP    0.0.0.0:49666          0.0.0.0:0              LISTENING       1608
  EventLog
 [svchost.exe]
  TCP    0.0.0.0:49667          0.0.0.0:0              LISTENING       1752
  Schedule
 [svchost.exe]
  TCP    0.0.0.0:49668          0.0.0.0:0              LISTENING       3356
 [spoolsv.exe]
  TCP    0.0.0.0:49680          0.0.0.0:0              LISTENING       912
 Не удается получить сведения о владельце
  TCP    127.0.0.1:80           0.0.0.0:0              LISTENING       5796
 [httpd.exe]
  TCP    127.0.0.1:80           127.0.0.1:51136        ESTABLISHED     5796
 [httpd.exe]
  TCP    127.0.0.1:80           127.0.0.1:62878        ESTABLISHED     5796
 [httpd.exe]
  TCP    127.0.0.1:443          0.0.0.0:0              LISTENING       5796
 [httpd.exe]
  TCP    127.0.0.1:3306         0.0.0.0:0              LISTENING       7016
 [mysqld.exe]
  TCP    127.0.0.1:9614         0.0.0.0:0              LISTENING       9780
 [javaw.exe]
  TCP    127.0.0.1:9614         127.0.0.1:57922        ESTABLISHED     9780
 [javaw.exe]
  TCP    127.0.0.1:51136        127.0.0.1:80           ESTABLISHED     2352
 [Code.exe]
  TCP    127.0.0.1:54612        127.0.0.1:54613        ESTABLISHED     9908
 [firefox.exe]
  TCP    127.0.0.1:54613        127.0.0.1:54612        ESTABLISHED     9908
 [firefox.exe]
  TCP    127.0.0.1:56020        127.0.0.1:56021        ESTABLISHED     14360
 [firefox.exe]
  TCP    127.0.0.1:56021        127.0.0.1:56020        ESTABLISHED     14360
 [firefox.exe]
  TCP    127.0.0.1:57922        127.0.0.1:9614         ESTABLISHED     6608
 [chrome.exe]
  TCP    127.0.0.1:58401        127.0.0.1:58402        ESTABLISHED     14576
 [firefox.exe]
  TCP    127.0.0.1:58402        127.0.0.1:58401        ESTABLISHED     14576
 [firefox.exe]
  TCP    127.0.0.1:58408        127.0.0.1:58409        ESTABLISHED     12412
 [firefox.exe]
  TCP    127.0.0.1:58409        127.0.0.1:58408        ESTABLISHED     12412
 [firefox.exe]
  TCP    127.0.0.1:58416        127.0.0.1:58417        ESTABLISHED     4672
 [firefox.exe]
  TCP    127.0.0.1:58417        127.0.0.1:58416        ESTABLISHED     4672
 [firefox.exe]
  TCP    127.0.0.1:60261        0.0.0.0:0              LISTENING       9104
 [Code.exe]
  TCP    127.0.0.1:60826        127.0.0.1:60827        ESTABLISHED     3224
 [firefox.exe]
  TCP    127.0.0.1:60827        127.0.0.1:60826        ESTABLISHED     3224
 [firefox.exe]
  TCP    127.0.0.1:62878        127.0.0.1:80           ESTABLISHED     2352
 [Code.exe]
  TCP    127.0.0.1:65327        127.0.0.1:65328        ESTABLISHED     10996
 [firefox.exe]
  TCP    127.0.0.1:65328        127.0.0.1:65327        ESTABLISHED     10996
 [firefox.exe]
  TCP    192.168.1.68:139       0.0.0.0:0              LISTENING       4
 Не удается получить сведения о владельце
  TCP    192.168.1.68:49899     95.142.204.155:443     ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:49925     95.142.204.152:443     ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:50112     216.58.209.202:443     ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:50319     151.101.129.69:443     ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:50329     35.201.97.85:443       ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:51911     13.107.42.18:443       ESTABLISHED     2352
 [Code.exe]
  TCP    192.168.1.68:51963     152.199.19.161:443     ESTABLISHED     2352
 [Code.exe]
  TCP    192.168.1.68:52635     192.168.1.106:8009     ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:52660     13.107.5.93:443        ESTABLISHED     2352
 [Code.exe]
  TCP    192.168.1.68:52661     152.199.19.161:443     ESTABLISHED     5524
 [SearchApp.exe]
  TCP    192.168.1.68:53414     95.142.204.186:443     ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:53637     95.142.204.158:443     ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:54419     151.101.65.69:443      ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:56247     104.22.70.197:443      ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:57006     140.82.121.6:443       ESTABLISHED     2352
 [Code.exe]
  TCP    192.168.1.68:58887     51.144.164.215:443     ESTABLISHED     2352
 [Code.exe]
  TCP    192.168.1.68:59202     93.186.225.201:443     ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:60146     74.125.131.188:5228    ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:60259     68.232.34.200:443      ESTABLISHED     2352
 [Code.exe]
  TCP    192.168.1.68:60527     204.79.197.200:443     ESTABLISHED     5524
 [SearchApp.exe]
  TCP    192.168.1.68:60528     40.101.50.210:443      ESTABLISHED     5524
 [SearchApp.exe]
  TCP    192.168.1.68:60529     40.101.50.194:443      ESTABLISHED     5524
 [SearchApp.exe]
  TCP    192.168.1.68:60530     13.107.136.254:443     ESTABLISHED     5524
 [SearchApp.exe]
  TCP    192.168.1.68:60532     204.79.197.254:443     ESTABLISHED     5524
 [SearchApp.exe]
  TCP    192.168.1.68:60533     204.79.197.222:443     ESTABLISHED     5524
 [SearchApp.exe]
  TCP    192.168.1.68:60534     152.199.19.161:443     ESTABLISHED     5524
 [SearchApp.exe]
  TCP    192.168.1.68:60535     13.107.4.254:443       ESTABLISHED     5524
 [SearchApp.exe]
  TCP    192.168.1.68:61922     87.240.129.129:443     ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:62114     20.54.37.73:443        ESTABLISHED     3704
  WpnService
 [svchost.exe]
  TCP    192.168.1.68:62466     35.167.57.186:443      ESTABLISHED     14576
 [firefox.exe]
  TCP    192.168.1.68:62879     128.75.237.17:443      CLOSE_WAIT      5524
 [SearchApp.exe]
  TCP    192.168.1.68:63742     77.88.21.119:443       ESTABLISHED     6608
 [chrome.exe]
  TCP    192.168.1.68:65022     192.168.1.106:8008     ESTABLISHED     6608
 [chrome.exe]
  TCP    [::]:135               [::]:0                 LISTENING       980
  RpcEptMapper
 [svchost.exe]
  TCP    [::]:445               [::]:0                 LISTENING       4
 Не удается получить сведения о владельце
  TCP    [::]:5357              [::]:0                 LISTENING       4
 Не удается получить сведения о владельце
  TCP    [::]:7680              [::]:0                 LISTENING       10452
 Не удается получить сведения о владельце
  TCP    [::]:8733              [::]:0                 LISTENING       4
 Не удается получить сведения о владельце
  TCP    [::]:49664             [::]:0                 LISTENING       924
 [lsass.exe]
  TCP    [::]:49665             [::]:0                 LISTENING       800
 Не удается получить сведения о владельце
  TCP    [::]:49666             [::]:0                 LISTENING       1608
  EventLog
 [svchost.exe]
  TCP    [::]:49667             [::]:0                 LISTENING       1752
  Schedule
 [svchost.exe]
  TCP    [::]:49668             [::]:0                 LISTENING       3356
 [spoolsv.exe]
  TCP    [::]:49680             [::]:0                 LISTENING       912
 Не удается получить сведения о владельце
  UDP    0.0.0.0:500            *:*                                    3596
  IKEEXT
 [svchost.exe]
  UDP    0.0.0.0:3702           *:*                                    4768
  FDResPub
 [svchost.exe]
  UDP    0.0.0.0:3702           *:*                                    1904
 [dashost.exe]
  UDP    0.0.0.0:3702           *:*                                    1904
 [dashost.exe]
  UDP    0.0.0.0:3702           *:*                                    4768
  FDResPub
 [svchost.exe]
  UDP    0.0.0.0:4500           *:*                                    3596
  IKEEXT
 [svchost.exe]
  UDP    0.0.0.0:5050           *:*                                    4656
  CDPSvc
 [svchost.exe]
  UDP    0.0.0.0:5353           *:*                                    6608
 [chrome.exe]
  UDP    0.0.0.0:5353           *:*                                    812
 [chrome.exe]
  UDP    0.0.0.0:5353           *:*                                    812
 [chrome.exe]
  UDP    0.0.0.0:5353           *:*                                    3004
  Dnscache
 [svchost.exe]
  UDP    0.0.0.0:5353           *:*                                    6608
 [chrome.exe]
  UDP    0.0.0.0:5355           *:*                                    3004
  Dnscache
 [svchost.exe]
  UDP    0.0.0.0:52863          *:*                                    4768
  FDResPub
 [svchost.exe]
  UDP    0.0.0.0:58440          *:*                                    6608
 [chrome.exe]
  UDP    0.0.0.0:65327          *:*                                    1904
 [dashost.exe]
  UDP    127.0.0.1:1900         *:*                                    2144
  SSDPSRV
 [svchost.exe]
  UDP    127.0.0.1:49666        *:*                                    3028
  iphlpsvc
 [svchost.exe]
  UDP    127.0.0.1:57854        *:*                                    2144
  SSDPSRV
 [svchost.exe]
  UDP    192.168.1.68:137       *:*                                    4
 Не удается получить сведения о владельце
  UDP    192.168.1.68:138       *:*                                    4
 Не удается получить сведения о владельце
  UDP    192.168.1.68:1900      *:*                                    2144
  SSDPSRV
 [svchost.exe]
  UDP    192.168.1.68:57853     *:*                                    2144
  SSDPSRV
 [svchost.exe]
  UDP    [::]:500               *:*                                    3596
  IKEEXT
 [svchost.exe]
  UDP    [::]:3702              *:*                                    1904
 [dashost.exe]
  UDP    [::]:3702              *:*                                    1904
 [dashost.exe]
  UDP    [::]:3702              *:*                                    4768
  FDResPub
 [svchost.exe]
  UDP    [::]:3702              *:*                                    4768
  FDResPub
 [svchost.exe]
  UDP    [::]:4500              *:*                                    3596
  IKEEXT
 [svchost.exe]
  UDP    [::]:5353              *:*                                    812
 [chrome.exe]
  UDP    [::]:5353              *:*                                    6608
 [chrome.exe]
  UDP    [::]:5353              *:*                                    3004
  Dnscache
 [svchost.exe]
  UDP    [::]:5355              *:*                                    3004
  Dnscache
 [svchost.exe]
  UDP    [::]:52864             *:*                                    4768
  FDResPub
 [svchost.exe]
  UDP    [::]:65328             *:*                                    1904
 [dashost.exe]
  UDP    [::1]:1900             *:*                                    2144
  SSDPSRV
 [svchost.exe]
  UDP    [::1]:57852            *:*                                    2144
  SSDPSRV
 [svchost.exe]
  UDP    [fe80::a91c:d22b:e39b:26f4%13]:1900  *:*                                    2144
  SSDPSRV
 [svchost.exe]
  UDP    [fe80::a91c:d22b:e39b:26f4%13]:57851  *:*                                    2144
  SSDPSRV
 [svchost.exe]
  • 1
    In your php.ini (and your `phpinfo()` confirms that) you are using port **9003** for Xdebug .. but in VSCode (launch.json) you still have **9000**. They HAVE to match otherwise VSCode listens on 9000 while Xdebug tries to connect on 9003 port. – LazyOne Oct 09 '21 at 08:36
  • Windows paths uses back slashes not forward slashes `zend_extension="C:/openserver/modules/php/PHP_8.0/ext/php_xdebug.dll" `. – Markus Zeller Oct 09 '21 at 09:12
  • @LazyOne, I changed the ports to the same wherever I could but it didn't help. Maybe you need to select a specific port? Or, again, I don’t know something. – John Egbert Oct 09 '21 at 10:03
  • @MarkusZeller I changed the path to zend_extension = "C:\openserver\modules\php\PHP_8.0\ext\php_xdebug.dll" but that didn't help either. – John Egbert Oct 09 '21 at 10:05
  • 1) Add `xdebug.start_with_request=yes` into your php.ini (do not forget to restart web server). Any better? Show new phpinfo output (or better `xdebug_info()` -- the same but just for Xdebug) 2) Make sure that VSCode is listening on that TCP 9003 port -- use `netstat` or alike tool confirm that 3) Enable Xdebug log -- it will show where it tries to connect and what the response is. https://www.youtube.com/watch?v=IN6ihpJSFDw – LazyOne Oct 09 '21 at 10:34
  • @LazyOne, https://sun9-48.userapi.com/impf/d8hnZehHyTDVYL7sIObFGwT4nXMNIiYsIEV9pw/wF_6rqH7EIo.jpg?size=729x1080&quality=96&sign=f24652565666a1a7eac59263a22ec9cb&type=album – John Egbert Oct 09 '21 at 11:05
  • @LazyOne https://sun9-3.userapi.com/impf/BkOOp-VtS6NMeDi2EKSyXyITB7Ni7o-YlcfUCw/d7VdnFgsOBg.jpg?size=555x625&quality=96&sign=6d85b73621cce2d8c7faed942f800e2d&type=album – John Egbert Oct 09 '21 at 11:07
  • 1) Use `netstat -abno` so it also lists what process is behind Xdebug port. Make sure it's VSCode; 2) VSCode must be listening on Xdebug port as it's Xdebug that connects to client and NOT other way around; 3) I see you have changed Xdebug port to be 9500. Did you do the same in VSCode? – LazyOne Oct 09 '21 at 11:37
  • @LazyOne Added information from netstat -abno to the question. And yes, I changed the port to 9500 everywhere. – John Egbert Oct 09 '21 at 11:55
  • I see no 9500 entries in netstat output. VSCode is not listening. Have you invoked your "Listen for Xdebug" configuration there (or whatever config you are using)? – LazyOne Oct 09 '21 at 13:16

1 Answers1

0

If you have a similar problem, then do the following (at least it helped me to solve it):

  1. Make sure you have the same ports specified in your php.ini and launch.json files.
  2. Set the xdebug.start_with_request=yes value to the rest of the php.ini values.
  3. And, perhaps an obvious point, CLICK ON Listen for Xdebug in vs code. I had a buggy editor when I clicked this button, but I just had to wait a little.

But there is a chance that all these steps will only help with identical initial settings.