XDebug 无法在 VScode 中进行 php 调试

pal*_*ope 3 php debugging visual-studio-code

即使在所有配置之后,使用 xdebug 和 xampp 在 vscode 中进行 PHP 调试也无法正常工作。

这是我的 php.ini 文件配置:

zend_extension = D:\Xampp\php\ext\php_xdebug-3.0.0-7.3-vc15-x86_64.dll
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
Run Code Online (Sandbox Code Playgroud)

这是 json 文件

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

    ]
}
Run Code Online (Sandbox Code Playgroud)

Rom*_*iaz 6

xDebug 3 更改了多个默认值,因此请确保您的代码已准备好使用新值。

这是我的配置集,它允许我像往常一样使用 PHP 断点:

.vscode\launch.json

{
    "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": 9000
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

php.ini(在文件末尾手动插入的行)

    [xdebug]
    zend_extension = "php_xdebug-3.0.4.dll"
    xdebug.mode = debug
    xdebug.discover_client_host = 1
    xdebug.start_with_request = yes
    xdebug.client_port = 9000
Run Code Online (Sandbox Code Playgroud)

注意:上面的选项将尝试在文件夹中zend_extension找到您的xdebug.../modules/php/PHP_%your_php_version%/ext/