我正在使用Visual Studio代码:
我还安装了PHP Debug Extension Version 1.12.1。我的PHP版本是:
>php --version
PHP 7.1.8 (cli) (built: Aug 1 2017 21:10:46) ( ZTS MSVC14 (Visual C++ 2015) x86 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
我按照PHP Debug
插件上的说明配置了xdebug。
我php.ini
中的设置如下所示:
zend_extension = "C:\xampp\php\ext\php_xdebug-2.5.5-7.1-vc14.dll"
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.idekey = "whatever"
运行phpinfo();
时,我的xdebug显示正确:
我的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
}
]
}
然而,在运行配置时,我得到:
错误日志如下所示:
messageService.ts:126 Debug adapter process has terminated unexpectedly
e.doShow @ messageService.ts:126
e.show @ messageService.ts:105
_.onServerExit @ rawDebugSession.ts:535
(anonymous) @ rawDebugSession.ts:449
emitTwo @ events.js:111
emit @ events.js:194
__dirname.ChildProcess._handle.onexit @ internal/child_process.js:215
有关调试可能出错的建议吗?
感谢您的回复!
答案 0 :(得分:0)
您的vscode
配置看起来很好(至少对于纯Windows PHP调试)。您的php.ini
Xdebug配置不必要地填充了不重要的东西(至少用于调试)。
摆脱整个事情并试试这个最小xdebug
配置:
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_connect_back = 1
xdebug.idekey = "whatever"
然后(如果您使用 Chrome ),您可以使用此扩展程序来管理启用/停用调试会话:Xdebug helper
注意:这是通过浏览器进行调试 - Chrome 。我想Firefox应该存在一些等效的插件,但我还没试过。如果在Windows 10上使用Linux或WSL,则可以通过在Linux终端中设置适当的环境变量export XDEBUG_CONFIG="idekey=whatever"
来启用调试会话。我认为纯Windows命令行存在一些等价物,但我也没有尝试过。