【问题标题】:VS Code Debugger - Felix Becker - Debugger doesn't hit anythingVS 代码调试器 - Felix Becker - 调试器没有遇到任何问题
【发布时间】:2021-03-26 17:48:54
【问题描述】:

我最近安装了 Felix Becker 的 php 调试器。 无论我做什么配置设置,我的调试器都没有遇到任何问题。 以下是我的 conf 文件。

xdebug.ini

[xdebug]
; debug
xdebug.default_enable = $value
xdebug.remote_autostart = $value
xdebug.remote_connect_back = 0
xdebug.remote_host = $value
xdebug.remote_port = $value
xdebug.remote_enable = 1
xdebug.idekey = $value

; profiling
xdebug.profiler_enable = 0
xdebug.profiler_output_dir = /tmp

zend_extension=xdebug.so

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": 9009,
            "pathMappings": {
                "path/path": "$value"
            }
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
  
            "port": 9009,
            "pathMappings": {
                "path/path": "$value"
            }
        }
    ]
  }

我这里有什么遗漏吗?

【问题讨论】:

  • 你的 PHP 和 Xdebug 版本是什么?
  • PHP 7.3.11 php debug by Felix Becker v1.13.0
  • 谢谢,但我询问了 Xdebug 版本(在 PHP 端进行调试的实际 PHP 扩展)而不是 VSCode 扩展。我之所以问,是因为 Xdebug v3 使用与 v2 不同的配置参数——也许这里也是如此。
  • Xdebug v3.0.1,作者 Derick Rethans
  • "Xdebug v3.0.1, by Derick Rethans" 在这种情况下,请通过xdebug.org/docs/upgrade_guide 并更新您的 Xdebug 配置。您正在使用 Xdebug v2 配置参数,v3 使用不同的配置参数。您当前的设置,在 v3 中几乎所有设置都不起作用。

标签: php visual-studio-code xdebug


【解决方案1】:

在 v1.52.1 中推送了对 Becker 扩展的修复,请参阅 https://github.com/microsoft/vscode/issues?q=is:issue+milestone:%22November+2020+Recovery%22+is:closed


Felix Becker 的 php 调试器扩展使用了以前不推荐使用的 api,因此最后一个 vscode 版本 1.52 意味着它不会遇到断点。 vscode的github上有很多关于这个的问题。一位 vscode 团队成员建议启用此设置来修复:

Debug: Allow Breakpoints Everywhere

https://github.com/microsoft/vscode/issues/112288#issuecomment-743456329

另一种选择是使用已更新其代码以适应弃用的不同扩展。示例见https://github.com/felixfbecker/vscode-php-debug/issues/424#issuecomment-727932756

【讨论】:

  • 感谢您的回答。我尝试了tiansin的新插件。它仍然是一样的。没有运气。
  • 你也试过设置吗?
  • 是的,马克。两种东西都试过了。它没有遇到任何断点。
  • 很抱歉。我将把答案留在这里,因为它给可能找到这个问题的人带来了很多悲伤。
【解决方案2】:

Xdebug v3.0.1,作者 Derick Rethans

您正在使用 Xdebug v3 但继续使用 Xdebug v2 配置参数。您需要通过Upgrading from Xdebug 2 to 3 Guide 并调整您的设置(主要是更改参数名称)。

Xdebug v3 使用 不同 配置参数而不是 Xdebug v2。从我看到的 9 个“xdebug”中的 8 个。当前 php.ini 中的参数在 Xdebug v3 中执行 nothing

对于 Xdebug 3,它应该是这样的(基于您的原始配置):

zend_extension=xdebug.so

[xdebug]
xdebug.mode = debug
; for profiling switch to below:
;xdebug.mode = profile

xdebug.client_host = ${PHP_XDEBUG_REMOTE_HOST}
xdebug.client_port = ${PHP_XDEBUG_REMOTE_PORT}
xdebug.discover_client_host = false
xdebug.start_with_request = ${PHP_XDEBUG_REMOTE_AUTOSTART}
xdebug.idekey = ${PHP_XDEBUG_IDE_KEY}
xdebug.output_dir = /tmp

附: xdebug.discover_client_host 现在将在失败时回退到 xdebug.client_host(与仅尝试自动检测主机的 v2 不同)。

附言xdebug.default_enable = 1 替换为 xdebug.mode = develop。如果需要,可以通过逗号列出多个值,例如xdebug.mode = develop,debug

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-08
    • 1970-01-01
    • 2013-10-04
    • 2023-03-29
    • 2016-03-18
    • 2011-10-29
    • 1970-01-01
    • 2016-11-15
    相关资源
    最近更新 更多