0

我已经浏览了我能找到的关于这个主题的每一篇文章,但我找不到解决方案。所以我不会把头发拉得更多,我会发布一个问题。

我有一个 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

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

我让 xdebug 在 PhpStorm 中没有问题,但在 VSCode 中没有运气。

4

1 回答 1

5

最新发布后v3.0.22**

其中包括对xdebug 3xdebug: debug的支持,您将需要config: php在您的.lando.yml

services:
  appserver:
    webroot: web
    xdebug: debug
    config:
      php: .lando.php.ini

一个.lando.php.ini文件

[PHP]
xdebug.mode=debug
xdebug.start_with_request = yes
xdebug.client_host = ${LANDO_HOST_IP}
xdebug.log = /tmp/xdebug.log

以及其中的 vscode.vscode/launch.json配置port: 9003

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Lando XDebug",
      "type": "php",
      "request": "launch",
      "port": 9003,
      "log": false,
      "pathMappings": {
        "/app/": "${workspaceFolder}/",
      }
    }
  ]
}

之前及最高版本v3.0.19

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

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Lando XDebug",
      "type": "php",
      "request": "launch",
      "port": 9000,
      "log": true,
      "pathMappings": {
        "/app/": "${workspaceRoot}/",
      }
    },
  ]
}

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

services:
  appserver:
    webroot: web
    xdebug: true
# no need for php.ini configuration
#    config:
#      php: .lando.php.ini

官方xdebug实际上指示

于 2020-12-08T06:13:44.053 回答