Xdebug V3 不会停止 VSCode 中的断点

ken*_*ian 7 php xampp xdebug visual-studio-code xdebug-3

我正在尝试使用 VSCode 在我的 XAMPP 上进行调试,但没有成功。我知道有很多关于这个的问题,我已经尽我所能,但仍然无法奏效。

关于我的 xdebug 扩展,你真的有一件很奇怪的事情。我目前使用的是 PHP v7.4.12 和 Xdebug 版本 3。

我知道我的 Xdebug 可以在 PHP 上运行,因为我查看了phpinfo()它并显示了我如何设置它。怪异的一部分是许多教程那里通常之中zend_extension = path..xdebug.remote_enable = 1并且xdebug.remote_autostart = 1应该足够,但是当我的phpinfo它看作是如下所示:

在此处输入图片说明

我试图用设置xdebug.remote_port = 9000xdebug.remote_host = "localhost",但仍然无法工作。我什至读过有关将 localhost 更改为的内容,127.0.0.1但仍然无效。

任何帮助,将不胜感激。这是我的 launch.json 文件和 php ini 文件。

配置文件

zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_log = "C:\xampp\tmp\xdebug\xdebug.log"
xdebug.remote_port = 9000
xdebug.remote_host = "127.0.0.1"
xdebug.idekey=VSCODE
Run Code Online (Sandbox Code Playgroud)

启动文件

{
    // 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": "Launch current script in console",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "externalConsole": false,
            "port": 9000
        },
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

如果是由于没有设置“pathMappings”引起的,谁能教我如何使用它?

顺便说一下 xdebug.log 也不起作用

Laz*_*One 25

您正在使用 Xdebug v3,但继续使用 Xdebug v2 配置参数。您需要通过从 Xdebug 2 升级到 3 指南并调整您的设置。

Xdebug v3 使用Xdebug v2不同的配置参数(您的phpinfo()输出在屏幕截图上准确地告诉您)。6 个“xdebug”中有 5 个。来自您当前 php.ini 的参数在 Xdebug v3 中没有任何作用。

对于 Xdebug 3,它应该是这样的(基于您的原始配置):

zend_extension = "C:\xampp\php\ext\php_xdebug.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)

  • 非常感谢。我已经这样做了两天了,但仍然做不到。原因是它现在正在工作。谢谢你! (5认同)

Ben*_*337 8

操作系统:Windows 10

VS Code 将断点标记为“未经验证的断点”。

就我而言,我必须添加“pathMappings”:

"configurations": [{
    ...,
    "pathMappings": {
        "remote/path/to/webroot/": "${workspaceFolder}",
    }
}]
Run Code Online (Sandbox Code Playgroud)

使用 docker 时的旁注:远程路径是 docker 容器内的路径。