【问题标题】:Is there a way to troubleshoot why Xdebug not stopping at breakpoints in VSCode?有没有办法解决为什么 Xdebug 没有在 VSCode 的断点处停止?
【发布时间】:2021-03-13 15:16:52
【问题描述】:

我一直在研究为什么 Xdebug 几天没有在断点处停止。我已经阅读并尝试了 StackOverflow 上的数十种解决方案。他们都没有工作。 有没有办法解决配置不工作的原因?。任何帮助将不胜感激,因为我已经解决这个问题好几天了。

我的设置:

我使用的是 Windows 10,它加载在驱动器 C 上。在我的 F: 驱动器上,我有 Laragon(本地服务器),其中包含我的 (PHP v7.2.19) 文件。我的 VSCode 也在 F: 驱动器上。 VSCode 使用 Felix Becker 的扩展 PHP Debug。

VSCode Launch.json:

"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
    }
]

我已按照 Xdebug 向导下载并安装了所有内容。下面是我在 Laragon 安装中的 php.ini 文件。

php.ini

[xdebug]
zend_extension = "F:\Laragon\bin\php\php-7.2.19-Win32-VC15-x64\ext\php_xdebug-3.0.0-7.2-vc15-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

扩展似乎已加载:

DEBUG     Checking PHPLS_ALLOW_XDEBUG
DEBUG     The xdebug extension is loaded (3.0.0)
DEBUG     Process restarting (PHPLS_ALLOW_XDEBUG=internal|3.0.0|0|*|*)
DEBUG     Running f:\laragon\bin\php\php-7.2.19-Win32-VC15-x64\php.exe -n -c C:\Users\Bill\AppData\Local\Temp\CA11.tmp c:\Users\Bill\.vscode\extensions\felixfbecker.php-intellisense-2.3.14\vendor\felixfbecker\language-server\bin\php-language-server.php --tcp=127.0.0.1:13121 --memory-limit=4095M

DEBUG     Checking PHPLS_ALLOW_XDEBUG
WARNING   Restarted (130 ms). The xdebug extension is loaded (3.0.0)

有没有办法解决我的设置问题?

【问题讨论】:

  • 1) Xdebug 3(您拥有的)使用与 Xdebug v2(您尝试在 php.ini 中使用的)不同的配置参数。请查看 Xdebug 3 的升级文档并使用正确的参数进行配置:xdebug.org/docs/upgrade_guide
  • 2) 您始终可以通过捕获phpinfo() 输出来检查当前Xdebug 配置,方法与您尝试调试的方式相同(网页或CLI)。只需查看 Xdebug 扩展的专用部分。 3) 配置完成后,一切看起来都很好,但仍然无法正常工作:启用并检查 Xdebug 日志——它会告诉它是否尝试连接到 VSCode、响应是什么等。

标签: php visual-studio-code xdebug laragon xdebug-3


【解决方案1】:

我使用 laravel 2.2.2 某些版本不适用于 x 调试,我在我的 php ini 文件中使用以下行代码 zend_extension = php_xdebug-2.9.8-7.1-vc14.dll 和 [XDebug] xdebug.remote_enable = 1 xdebug.remote_autostart = 1

【讨论】:

    【解决方案2】:

    感谢 LazyOne 将我引导至 cmets 中的答案。问题是,当我应该使用 XDebug 3 时,我使用的是 XDebug 2 参数。也感谢 WebEXP0528 发布建议的答案。但是,对网站的引用确实帮助我理解了为什么要更改 php.ini 文件。网页参考 xdebug.org/docs/upgrade_guide 提供了很多帮助我解决问题的信息。

    旧:

    [xdebug]
    zend_extension = "F:\Laragon\bin\php\php-7.2.19-Win32-VC15-x64\ext\php_xdebug-3.0.0-7.2-vc15-x86_64.dll"
    xdebug.remote_enable = 1
    xdebug.remote_autostart = 1
    

    基于 xdebug.org/docs/upgrade_guide 的新 php.ini:

    [xdebug]
    zend_extension = "F:\Laragon\bin\php\php-7.2.19-Win32-VC15-x64\ext\php_xdebug-3.0.0-7.2-vc15-x86_64.dll"
    xdebug.mode = debug
    xdebug.start_with_request = yes
    xdebug.discover_client_host = 1
    

    【讨论】:

    • 谢谢!!!!我已经为此苦苦挣扎了好久......
    【解决方案3】:

    在 php.ini 中

    [xdebug]
    zend_extension = "F:\Laragon\bin\php\php-7.2.19-Win32-VC15-x64\ext\php_xdebug-3.0.0-7.2-vc15-x86_64.dll"
    xdebug.mode=debug
    xdebug.idekey=VSCODE
    xdebug.start_with_request=yes
    xdebug.client_host=127.0.0.1
    xdebug.client_port=9001
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-31
      • 2021-12-18
      • 2017-01-24
      • 2021-06-29
      • 1970-01-01
      • 1970-01-01
      • 2016-02-18
      • 2012-05-01
      相关资源
      最近更新 更多