VSCode调试器跳过断点

时间:2019-09-26 23:14:38

标签: php windows visual-studio-code xdebug

当我在VSCode上启动调试器时,一切似乎都在工作,因为下部的条变为橙色等。但是,当我添加一个断点时,站点将忽略它并保持正常加载。当我去在launch.json上添加配置时,php也没有出现。 Xdebug不会创建日志。

我已经仔细检查了所有路径,下载了Xdebug的dll,并在php.ini,settings.json和launch.json上添加了必要的行。

php -v给了我7.3.5版本,在WAMP上是相同的版本(在台式机和http://localhost/?phpinfo=-1上已验证)

settings.json

{
    "telemetry.enableTelemetry": false,
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    "window.zoomLevel": -1,
    "C_Cpp.updateChannel": "Insiders",
    "arduino.path": "C:\\Program Files (x86)\\Arduino",
    "[javascript]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "[html]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "editor.minimap.enabled": false,
    "php.validate.enable": true,
    "php.executablePath": "c:/wamp64/bin/php/php7.3.5/php.exe",
    "php.validate.executablePath": "c:/wamp64/bin/php/php7.3.5/php.exe",
    "php.validate.run": "onSave",
    "files.associations": {
        "*.inc": "php"
    },
    "git.autofetch": true,
    "git.enableSmartCommit": true
}

launch.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": 9000
        }
    ]
}

php.ini

[XDebug]
zend_extension="c:/wamp64/bin/php/php7.3.5/ext/php_xdebug-2.8.0beta2-7.3-vc15-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart=on
xdebug.remote_port = 9000
xdebug.remote_log="c:/"

我也没有收到任何错误消息。

2 个答案:

答案 0 :(得分:1)

进行日志记录:可能不允许Web服务器写入c:/-您可能想使用c:/temp(或任何临时目录路径)。

关于不停止,Web服务器的路径和硬盘上本地的路径可能不相同,并且您需要设置“路径映射”:https://github.com/felixfbecker/vscode-php-debug/blob/master/README.md#remote-host-debugging

答案 1 :(得分:1)

我在这个问题上苦苦挣扎了一年多,但在我的案子中发现了这个问题。

VSCode python调试器将仅在行尾识别CRLF或LF,但不能识别两者。当文件中两者混合时,调试器似乎会跳过行(但它们仍会执行)。就我而言,这是因为我在调试会话期间添加了代码行,并且当我在调试器会话中保存文件时,行尾字符与文件中的默认字符不同。

要解决此问题,我只需要将VSCode底部蓝色条右侧的换行设置从CRLF更改为LF,再更改回CRLF并保存文件即可。

相关问题