php - VSCode 调试器跳过断点
问题描述
当我在 VSCode 上启动调试器时,一切似乎都在工作,因为下栏变成橙色等......但是,当我添加断点时,站点会忽略它并保持正常加载。当我在launch.json 上添加配置时,php 也不会出现。Xdebug 不会创建日志。
我仔细检查了所有路径,下载了 Xdebug 的 dll,并在 php.ini、settings.json 和 launch.json 中添加了必要的行。
php -v
给我版本 7.3.5 和 WAMP 它是相同的版本(在桌面和验证http://localhost/?phpinfo=-1
)
设置.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
}
启动.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:/"
我也没有收到任何错误消息。
解决方案
我在这个问题上苦苦挣扎了一年多,但在我的情况下发现了这个问题。
VSCode python 调试器只能识别行尾的 CRLF 或 LF,但不能同时识别两者。当文件中同时存在两者时,调试器将显示为跳过行(但它们仍会被执行)。这发生在我的案例中,因为我在调试会话中添加了代码行,并且当我使用调试器会话保存文件时,行尾字符与文件中的默认字符不同。
为了解决这个问题,我只需将 VSCode 底部蓝色条右侧的换行设置从 CRLF 更改为 LF 回到 CRLF 并保存文件。
推荐阅读
- java - 使用 maven 运行时,测试套件挂起。在 IDEA 中使用 Junit 运行配置运行良好
- angular-material - 如何通过角材料的垫选实现数据列表?
- python - ValueError:要解包的值太多(预期为 3)-正则表达式匹配-Python
- node.js - 尝试从文件夹中的文件而不是NodeJS中的根目录中读取时无法识别.env文件
- visual-studio-code - 如何在 VS Code 中选择多个方法?
- gstreamer - Gstreamer 管道无法使用 osxaudiosrc 插件运行
- sql - 模块导出事件 discord.js 的参考错误
- python - 尝试在 Pandas Dataframe 上使用 Regex 时出现 TypeError
- c++ - C++ Primer 5 ed.1.23 从文件流中读取
- c++ - 从目标文件 (.o) 在 macOS 上制作存档文件 (.a 文件)