有没有办法解决 Xdebug 为什么不在 VSCode 中的断点处停止的问题?

Is there a way to troubleshoot why Xdebug not stopping at breakpoints in VSCode?

几天来我一直在研究为什么 Xdebug 不在断点处停止。我在 Whosebug 上阅读并尝试了数十种解决方案。 None 其中有效果。 是否有解决配置不起作用的方法?。任何帮助将不胜感激,因为我已经处理这个问题好几天了。

我的设置:

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

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)

是否有解决我的设置问题的方式或方法?

在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

感谢 LazyOne 引导我在评论中找到答案。问题是,当我应该使用 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 的新 php.ini。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.mode = debug
xdebug.start_with_request = yes
xdebug.discover_client_host = 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