无法让 Xdebug 与 Lando 和 VSCode 一起工作。立即连接并停止

0 configuration xdebug visual-studio-code lando

我已经浏览了我能找到的关于这个主题的所有帖子,但我找不到解决方案。因此,与其将头发拉得更远,我将发布一个问题。

我有一个 Lando 安装(运行 Drupal 8,但我正在测试一个简单的phpinfo()脚本),Xdebug 确认正在运行。每当我添加断点并运行脚本时,它都无法停止。

用于 Xdebug 的自定义 Lando .ini:

[PHP]

Xdebug
xdebug.max_nesting_level = 256
xdebug.show_exception_trace = 0
xdebug.collect_params = 0
; Extra custom Xdebug setting for debug to work in VSCode.
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_host = ${LANDO_HOST_IP}
xdebug.remote_connect_back = 0
xdebug.remote_mode = req
xdebug.remote_autostart = On
xdebug.remote_log = /tmp/xdebug.log
xdebug.idekey = VSCODE

max_execution_time = 0
Run Code Online (Sandbox Code Playgroud)

xdebug.log 的输出

245] Log opened at 2020-09-09 14:42:21
[245] I: Connecting to configured address/port: host.docker.internal:9000.
[245] I: Connected to client. :-)
[245] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///app/web/info.php" language="PHP" xdebug:language_version="7.3.22" protocol_version="1.0" appid="245" idekey="VSCODE"><engine version="2.9.6"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

[245] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

[245] Log closed at 2020-09-09 14:42:21
Run Code Online (Sandbox Code Playgroud)

我的 xdebug 在 PhpStorm 中没有问题,但在 VSCode 中没有问题。

Gio*_*osK 5

最新发布v3.0.22 之后**

其中包括支持XDebug的3,你将需要xdebug: debugconfig: php设置在.lando.yml

services:
  appserver:
    webroot: web
    xdebug: debug
    config:
      php: .lando.php.ini
Run Code Online (Sandbox Code Playgroud)

一个.lando.php.ini文件

[PHP]
xdebug.mode=debug
xdebug.start_with_request = yes
xdebug.client_host = ${LANDO_HOST_IP}
xdebug.log = /tmp/xdebug.log
Run Code Online (Sandbox Code Playgroud)

和vscode配置在.vscode/launch.jsonport: 9003

[PHP]
xdebug.mode=debug
xdebug.start_with_request = yes
xdebug.client_host = ${LANDO_HOST_IP}
xdebug.log = /tmp/xdebug.log
Run Code Online (Sandbox Code Playgroud)

在v3.0.19发布之前和之前

我能够使用此配置使用 vscode 运行lando xdebug .vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Lando XDebug",
      "type": "php",
      "request": "launch",
      "port": 9003,
      "log": false,
      "pathMappings": {
        "/app/": "${workspaceFolder}/",
      }
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我没有php.ini在我的.lando.yml

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Lando XDebug",
      "type": "php",
      "request": "launch",
      "port": 9000,
      "log": true,
      "pathMappings": {
        "/app/": "${workspaceRoot}/",
      }
    },
  ]
}
Run Code Online (Sandbox Code Playgroud)

官员Xdebug的实际指导