Xdebug - Visual Studio 代码 - 进入/跳过 - 没有任何反应
Xdebug - Visual Studio Code - Step into / Step over - Nothing happens
我遇到了 Visual Studio 代码和 Xdebug 的问题。
我的系统:
我正在使用带有 IIS
网络服务器和 PHP
版本 7.4 的 Windows 10
系统。
我已经成功下载并安装了最新版本 (2.9.0) 的 Xdebug
(请参阅下面 php.ini
的摘录)。
Visual Studio 代码已配置为使用 Xdebug(请参阅下面的 launch.json
文件)。
我的问题是:
当我设置断点时,它会停在这个断点处。到目前为止,一切都很好。但是,如果我按下 "Step into" (F11) 或 "Step over" (F10) 按钮,则什么也没有发生。初始断点仍然突出显示 - 它停留在断点处。
可能配置有误,但实际上我想不通是什么。
查看配置文件:
php.ini:
[XDEBUG]
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
xdebug.idekey=VSCODE
xdebug.remote_log ="C:\temp\xdebug.log"
[PHP_XDEBUG-2.9.0-7.4-VC15-NTS]
zend_extension = "C:\Program Files (x86)\PHP\v7.4\ext\php_xdebug-2.9.0-7.4-vc15-nts-x86_64.dll"
launch.json 共 Visual Studio 代码:
{
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"ignore": [
"**/vendor/**/*.php"
]
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
这原来是 Xdebug 中的一个 bug,当以下几点都为真时会发生:
- error handler 将 warning/notice 转换为异常
- 在此特定异常上设置了异常断点,或者设置了通配符异常断点
- IDE 通常用于实现监视的 DBGp
eval command
创建了一个警告或通知,在这种情况下,由于未定义的变量。
原因是虽然eval
命令用breakpoints_allowed标志转断点,直到运行,断点exceptions 的处理程序没有检查这个 breakpoints_allowed 标志是否实际设置。
fix is to check for the breakpoints_allowed flag in the handler for exception breakpoints, and will be part of the upcoming Xdebug 2.9.2 release. If you don't want to wait, download Xdebug from Github 并确保使用 xdebug_2_9
分支(除非你想真正进行实验)。
我遇到了 Visual Studio 代码和 Xdebug 的问题。
我的系统:
我正在使用带有 IIS
网络服务器和 PHP
版本 7.4 的 Windows 10
系统。
我已经成功下载并安装了最新版本 (2.9.0) 的 Xdebug
(请参阅下面 php.ini
的摘录)。
Visual Studio 代码已配置为使用 Xdebug(请参阅下面的 launch.json
文件)。
我的问题是:
当我设置断点时,它会停在这个断点处。到目前为止,一切都很好。但是,如果我按下 "Step into" (F11) 或 "Step over" (F10) 按钮,则什么也没有发生。初始断点仍然突出显示 - 它停留在断点处。
可能配置有误,但实际上我想不通是什么。
查看配置文件:
php.ini:
[XDEBUG]
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
xdebug.idekey=VSCODE
xdebug.remote_log ="C:\temp\xdebug.log"
[PHP_XDEBUG-2.9.0-7.4-VC15-NTS]
zend_extension = "C:\Program Files (x86)\PHP\v7.4\ext\php_xdebug-2.9.0-7.4-vc15-nts-x86_64.dll"
launch.json 共 Visual Studio 代码:
{
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"ignore": [
"**/vendor/**/*.php"
]
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
这原来是 Xdebug 中的一个 bug,当以下几点都为真时会发生:
- error handler 将 warning/notice 转换为异常
- 在此特定异常上设置了异常断点,或者设置了通配符异常断点
- IDE 通常用于实现监视的 DBGp
eval command
创建了一个警告或通知,在这种情况下,由于未定义的变量。
原因是虽然eval
命令用breakpoints_allowed标志转断点,直到运行,断点exceptions 的处理程序没有检查这个 breakpoints_allowed 标志是否实际设置。
fix is to check for the breakpoints_allowed flag in the handler for exception breakpoints, and will be part of the upcoming Xdebug 2.9.2 release. If you don't want to wait, download Xdebug from Github 并确保使用 xdebug_2_9
分支(除非你想真正进行实验)。