php - Xdebug V3 不会停止 VSCode 中的断点

标签 php visual-studio-code xampp xdebug xdebug-3

我正在尝试使用 VSCode 在我的 XAMPP 上进行调试,但没有成功。我知道有很多关于这个的问题,我已经尽我所能,但仍然无法奏效。
关于我的 xdebug 扩展,你真的有一件很奇怪的事情。我目前使用的是 PHP v7.4.12 和 Xdebug 版本 3。
我知道我的 Xdebug 可以在 PHP 上运行,因为我查看了 phpinfo()它显示了我如何设置它。奇怪的部分是通常在那里的许多教程中的一部分 zend_extension = path.. , xdebug.remote_enable = 1xdebug.remote_autostart = 1应该足够了,但是当我查看 phpinfo 时,如下所示:
enter image description here
我试着用 xdebug.remote_port = 9000 设置它和 xdebug.remote_host = "localhost"但仍然无法正常工作。我什至读过将 localhost 更改为 127.0.0.1但仍然没有用。
任何帮助,将不胜感激。这是我的 launch.json 文件和 php ini 文件。
php.ini

zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_log = "C:\xampp\tmp\xdebug\xdebug.log"
xdebug.remote_port = 9000
xdebug.remote_host = "127.0.0.1"
xdebug.idekey=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": "Launch current script in console",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "externalConsole": false,
            "port": 9000
        },
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        }
    ]
}
如果是由于没有设置“pathMappings”引起的,谁能教我如何使用它?
顺便说一下 xdebug.log 也不起作用

最佳答案

您正在使用 Xdebug v3,但继续使用 Xdebug v2 配置参数。您需要通过Upgrading from Xdebug 2 to 3 Guide并调整您的设置。
Xdebug v3 使用 不同 config params 比 Xdebug v2(您的 phpinfo() 输出在您的屏幕截图上准确地告诉您)。 6 个“xdebug”中有 5 个。来自您当前 php.ini 的参数做 没什么在 Xdebug v3 中。
对于 Xdebug 3,它应该是这样的(基于您的原始配置):

zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
xdebug.client_host = "127.0.0.1"
xdebug.log = "C:\xampp\tmp\xdebug\xdebug.log"
xdebug.idekey = VSCODE

关于php - Xdebug V3 不会停止 VSCode 中的断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65137732/

相关文章:

php - CakePHP 管理部分路由和重定向

javascript - 尝试在 WordPress 中使用 Ajax 时收到 400 错误请求

javascript - 是否可以在 VSCode 中自动完成相对路径

python - 错误 : No similarly named formulae found. 错误:没有名称为 "python"的可用公式或桶

php - 从/var/www 文件夹运行 php 程序

perl - 如何在Windows上通过XAMPP运行Perl文件?

php - 在 XAMPP 上运行 PHP 文件与在 php 命令行上运行

php - 在 symfony 2 中使用 Codeception 验收测试

php - 如何使用 PHP 代码而不是 HTML 代码导入/包含 CSS 文件?

visual-studio-code - VSCode - 将文件类型图标添加到快速选择列表