0

第二天,我一直在尝试将 Xdebug 连接到我的开放服务器项目,但它拒绝工作。我已经阅读了很多文章并尝试了所有不同的选项,但仍然无法达到断点。下面我将发送我拥有的所有参数,如果您能帮助我解决我的问题,我将不胜感激。

来自 php_info() 的信息: 在此处输入图像描述

VSCode 的扩展: 在此处输入图像描述

php.ini 信息:

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"

启动.json 信息:

{
    // 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"
            }
        }
    ]
}

此外,根据一些文章的建议,我在 Firefox 中安装了 Xdebug 助手。

网络统计-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]
4

1 回答 1

0

如果您有类似的问题,请执行以下操作(至少它帮助我解决了它):

  1. 确保您在 php.ini 和 launch.json 文件中指定了相同的端口。
  2. 将该xdebug.start_with_request=yes值设置为 php.ini 的其余值。
  3. 而且,也许很明显,Listen for Xdebug在 vs 代码中单击。当我点击这个按钮时,我有一个错误的编辑器,但我只需要稍等片刻。

但是有可能所有这些步骤只会对相同的初始设置有所帮助。

于 2021-10-09T14:45:34.523 回答