Xdebug - 调试适配器进程意外终止

问题描述 投票:0回答:1

我正在使用Visual Studio代码:

enter image description here

我还安装了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显示正确:

enter image description here

我的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
        }
    ]
}

但是,在运行配置时,我得到:

enter image description here

错误日志如下所示:

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

有什么建议调试可能有什么问题吗?

感谢您的回复!

php visual-studio visual-studio-code xdebug
1个回答
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命令行中存在一些等价物,但我也没有尝试过。

© www.soinside.com 2019 - 2024. All rights reserved.