无法打开/关闭 xdebug 步骤调试器功能

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

我无法通过 ini 文件设置可靠地打开/关闭 XDEBUG“单步调试器”功能。

我知道我应该能够在 xdebug/php.ini 文件中执行此操作,基本上可以在关闭和调试之间切换 xdebug.mode 的值。

此操作会切换 phpinfo() 和 xdebug_info() 页面报告的 xdebug.mode 参数的值,但不会切换 phpinfo() 或 xdebug_info() 中的“单步调试器”功能的状态。

如果我能切换它,调试效果就很好。但是,如果我无法通过尝试和错误重置 .ini 文件来进行切换,则调试将不起作用,并且我不会在 xdebug.log 中收到任何错误。

如果我能够启用“单步调试器”功能,有时我仍然无法调试,并且在 xdebug.log 中收到此错误:

[17414] [Step Debug] ERR: Could not connect to debugging client. Tried: 0.0.0.0:9003 (through xdebug.client_host/xdebug.client_port).

话又说回来,有时它确实有效!

客户端 视窗11 VSCode 版本 1.92.2 远程 - SSH 版本 v0.113.1 PHP 调试版本 1.35.0

服务器端 Ubuntu 22.04.4 LTS XDEBUG 版本 3.3.2 Apache2 版本 2.4.52

/etc/php/8.1/fpm/conf.d/20-xdebug.ini

zend_extension=xdebug.so
xdebug.mode = off
xdebug.client_host = localhost
xdebug.connect_timeout_ms = 500
xdebug.log = "/var/log/xdebug.log"
xdebug.log_level=2

website specific php.ini

xdebug.mode = debug
xdebug.client_host = 0.0.0.0
xdebug.start_with_request = yes
xdebug.discover_client_host = yes
xdebug.log_level = 7

如您所见,我正在覆盖网站特定 php.ini 文件中的一些 xdebug.ini 值。正如我所提到的,这些 oversires 由 phpinfo() 和 xdebuf_info() 函数获取并在其页面中正确报告。

澄清一下,在 20-xdebug.ini 文件中启用 xdebug.mode 没有什么区别。

我的期望是,每当我更改 ini 文件中 xdebug.mode 的值时,它都会显示 XDEBUG 扩展的“单步调试器”功能。

我是否遗漏了一些概念或配置细节?谢谢

php visual-studio-code debugging xdebug-3
2个回答
0
投票

尝试使用您的 wifi 适配器/以太网适配器的 IPv4 地址作为 client_host。您可以在终端中写入 ipconfig 来获取 IPv4。

$ ipconfig

设置client_port=9003。 为 vscode 创建 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": 9003,
      "pathMappings": {
        "/var/www": "${workspaceFolder}"
      }
    }
  ]
}

0
投票

Grisho4ek,感谢您的建议。

事实证明问题不是 VSCODE 而是我的 Ubuntu 服务器以及我处理 xdebug.ini 文件的方式。

我在“/etc/php/8.1/fpm/conf.d/20-xdebug.ini设置”中设置了所需的xdebug参数默认值,设置“xdebug.mode = off”并覆盖“xdebug.mode = debug”稍后在我的网站特定的 xdebug.ini 文件。这样做会覆盖 xdebug 参数的值,但由于某种原因,它对 Xdebug 功能没有影响,因此我无法切换单步调试器。

不知道为什么 xdebug 参数被覆盖而功能没有被覆盖,但就这样吧:它似乎是这样工作的。我认为问题已解决。

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