【问题标题】:Xdebug - Debug adapter process has terminated unexpectedlyXdebug - 调试适配器进程意外终止
【发布时间】:2017-12-26 16:08:49
【问题描述】:

我正在使用 Visual Studio 代码:

我还安装了 PHP 调试扩展版本 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

有什么建议可以调试吗?

感谢您的回复!

【问题讨论】:

  • 你的 xdebug.ini 设置是什么?
  • @Farkie Thx 为您解答!我没有xdebug.ini 文件。但是,我使用php.ini 文件中的xdebug 设置更新了我的答案。

标签: php visual-studio-code xdebug


【解决方案1】:

您的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 命令行存在一些等价物,但我也没有尝试过。

【讨论】:

  • 感谢您的回答!我按照描述配置了我的 php.ini 文件。但是,我仍然遇到同样的错误。我正在尝试调试 laravel 命令,因此需要在本地运行 xdebug ...
  • 太糟糕了 :/ 我肯定会推荐 (如果你有 Windows 10) 安装 WSL 并运行 Apache、PHP i>、DB 等。与纯 Windows 相比,它对开发人员和配置更友好(甚至更快)。如果这不是您想尝试的,我会检查vscode 的devtools 控制台中是否有任何线索,我会检查PHP 的error.log 文件中是否有任何东西,我会尝试vscode 中的putting "log": true' s "Listen for XDebug" 调试配置并查看是否有任何线索出现。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-25
  • 1970-01-01
  • 1970-01-01
  • 2010-09-27
  • 2014-08-13
相关资源
最近更新 更多