【问题标题】:Xdebug V3 doesn't stop breakpoints in VSCodeXdebug V3 不会停止 VSCode 中的断点
【发布时间】:2021-03-16 03:54:01
【问题描述】:

我正在尝试使用 VSCode 在我的 XAMPP 上进行调试,但没有成功。我知道有很多关于这个的问题,我已经尝试了所有我能做的,但仍然无法工作。

我的 xdebug 扩展确实有一件奇怪的事情。我目前使用的是 PHP v7.4.12 和 Xdebug 版本 3。

我知道我的 Xdebug 可以在 PHP 上运行,因为我查看了 phpinfo(),它显示了我是如何设置它的。奇怪的部分在许多教程中,通常zend_extension = path..xdebug.remote_enable = 1xdebug.remote_autostart = 1 应该足够了,但是当我查看 phpinfo 时,如下所示:

我尝试使用xdebug.remote_port = 9000xdebug.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 也不起作用

【问题讨论】:

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


    【解决方案1】:

    您正在使用 Xdebug v3 但继续使用 Xdebug v2 配置参数。您需要通过Upgrading from Xdebug 2 to 3 Guide 并调整您的设置。

    Xdebug v3 使用与 Xdebug v2 相比不同的配置参数(您的phpinfo() 输出在您的屏幕截图上准确地告诉了您)。 6 个中有 5 个“xdebug”。当前 php.ini 中的参数在 Xdebug v3 中执行 nothing

    对于 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
    

    【讨论】:

    • 非常感谢。我现在这样做了2天,但仍然无法做到。因此,它现在正在工作。谢谢!
    • 非常感谢
    • 谢谢,ppa:ondrej/php 在没有通知的情况下将 xdebug 从 V2 更改为 V3,一切都被破坏了
    • 将上面的端口更改为 9003,我相信 VSCODE 可以开箱即用。
    • @EricSebasta 这个答案是针对那个特定问题的——特别是因为它说“基于你的原始配置”。我相信您和其他人在复制某些内容时不会进行 StackOverflow 编程,而无需阅读它的实际作用以及如何根据您的特定情况对其进行调整。 但是是的,将端口更改为 9003(或简单地删除该行,因为它现在是默认端口)将更适合新设置/新用户
    猜你喜欢
    • 2021-06-29
    • 2011-04-30
    • 2018-03-31
    • 1970-01-01
    • 2019-07-31
    • 1970-01-01
    • 2014-11-22
    • 2014-06-19
    相关资源
    最近更新 更多