Visual Studio代码不会在PHP Xdebug中的断点处停止

sil*_*one 4 php xdebug visual-studio-code

我从Thinkpad笔记本电脑转到HP Elitebook.我必须在我的新笔记本电脑中设置我的开发环境.在Windows 10 Pro 64位版本中设置我的Visual Studio代码和XAMPP后,我无法调试我的PHP代码.

我已经为Visual Studio Code正确安装了Xdebug扩展,并确保php.ini正确.这是我的设置php.ini(我使用便携式XAMPP放在E:驱动器上):

zend_extension = "E:\xampp\php\ext\php_xdebug-2.4.1-5.4-vc9.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_log="E:\xampp\apache\logs\xdebug.log"
Run Code Online (Sandbox Code Playgroud)

我的xdebug.log显示如下信息:

Log opened at 2018-10-27 05:56:45
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///E:/xampp/htdocs/absen/index.php" language="PHP" xdebug:language_version="5.4.3-dev" protocol_version="1.0" appid="7112" idekey="william"><engine version="2.4.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

Log closed at 2018-10-27 05:56:45
Run Code Online (Sandbox Code Playgroud)

但我的Visual Studio代码不会在断点处停止.

我已重新安装我的Visual Studio代码,XAMPP,并使用另一个Xdebug版本,但它仍然无法正常工作.

我有以下链接:

这些解决方案都不起作用.

小智 12

这就是解决我遇到的同样问题的方法,如果以前的答案没有帮助,值得一试

php.ini

 [XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-3.0.2-8.0-vs16-x86_64.dll"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
xdebug.client_host = "127.0.0.1"
xdebug.log = "C:\xampp\tmp\xdebug\xdebug.log"
xdebug.idekey = VSCODE
Run Code Online (Sandbox Code Playgroud)

启动.json

"configurations": [
    {
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch",
      "port": 9000
    },
    {
      "type": "php",
      "request": "launch",
      "name": "Run using local PHP Interpreter",
      "program": "${file}",
      "runtimeExecutable": "C:\\xampp\\php\\php.exe"
    }
  ]
Run Code Online (Sandbox Code Playgroud)


sil*_*one 10

最后我知道问题的根源.HP Elitebook预装了名为HP Velocity的程序,该程序使用端口9000.

问题是我的主机端口9000绑定到HP Velocity软件的端口9000.当HP Velocity服务连接到localhost xdebug服务器时,日志表明连接正常,但它已连接到HP Velocity.

我在php.ini中将xdebug端口更改为9090,并在visual studio代码中的launch.json中进行了更改.之后,我的visual studio代码照常工作,可以在断点处停止.

希望这能帮到别人:)


Nic*_*Yap 8

就我而言,这pathMappings是不正确的,并且没有更改端口

{
    ...
    "configurations": [
        {
            ...
            "port": 9000,
            "pathMappings": {
                "/var/www/yourproject": "${workspaceFolder}/",
             }
          }
      ]
  }
Run Code Online (Sandbox Code Playgroud)

如果我检查“Everything”断点,我的断点实际上正在工作(它捕获了抑制的异常,但 VS 代码警告未找到该文件)


小智 6

就我而言,我试图在本地计算机上调试 php 脚本,因此我必须意识到我必须使用 Web 服务器正在使用的端口(在我的例子中为 8080)而不是使用端口来调试 php 脚本在 VS Code 配置上设置(我使用 9090)。

对于遇到此错误的任何人,这是我的配置:

  • 操作系统:Windows 10 64 位
  • PHP 5.6(32 位 TS)
  • Xdebug 2.5.5(32 位)
  • 阿帕奇 2.4(32 位)
  • Google Chrome 上安装的 Xdebug Helper

1)httpd.conf

阿帕奇端口

2) php.ini(XDebug 部分)

X调试端口

3)launch.json(VS Code配置)

在此输入图像描述