Ben*_*bin 10 php xdebug visual-studio-code
我正在尝试使用 XDebug 和 Visual Studio Code 在 PHP 代码中设置断点,这些代码都安装在 Ubuntu Hyper-V 虚拟机上。我使用的是 PHP 7.2。
每当我在 PHP 代码中设置断点并刷新应该命中断点的页面时,我都会收到错误“命令不可用”和“没有这样的断点”显示在 Visual Studio 代码的弹出窗口中。我还在调试控制台中收到以下错误。
XDebugError: command is not available
at new Response (/home/ben/.vscode/extensions/felixfbecker.php-debug-
1.13.0/out/xdebugConnection.js:56:19)
at new BreakpointSetResponse (/home/ben/.vscode/extensions/felixfbecker.php-debug-
1.13.0/out/xdebugConnection.js:207:9)
at Connection.<anonymous> (/home/ben/.vscode/extensions/felixfbecker.php-debug
1.13.0/out/xdebugConnection.js:599:20)
at Generator.next (<anonymous>)
at fulfilled (/home/ben/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/xdebugConnection.js:4:58) {
code: 5,
name: 'XDebugError'
}
Run Code Online (Sandbox Code Playgroud)
根据我的研究,我认为问题在于 XDebug 不适用于 IPv6,但调试器正在侦听 v6。如果我这样做netstat -an | grep 9000,我得到
tcp6 0 0 :::9000 :::* LISTEN
Run Code Online (Sandbox Code Playgroud)
以下是内容 /etc/php/7.2/fpm/conf.d/20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.var_display_max_depth=-1
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
Run Code Online (Sandbox Code Playgroud)
我如何解决这个问题并使我的断点工作?
我使用这些扩展进行调试:
请检查您的项目的 XDebug 配置。它是项目根目录下.vscode文件夹中的launch.json 。如果缺少,则必须在 Visual Studio Code 的调试设置中创建(齿轮按钮)。
它应该看起来像这样:
{
// 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}"
}
]
Run Code Online (Sandbox Code Playgroud)
}
| 归档时间: |
|
| 查看次数: |
709 次 |
| 最近记录: |