【问题标题】:Can't debug php with VS Code无法使用 VS Code 调试 php
【发布时间】:2017-01-27 14:26:21
【问题描述】:

我正在尝试使用 wamp、xdebug 和 this 扩展名调试我的 php,但我无法让它工作。我的php.ini到此结束(C:\wamp64\bin\php\php7.0.4\php.ini):

[Xdebug]
zend_extension ="C:/wamp64/bin/php/php7.0.4/ext/php_xdebug-2.4.1-7.0-vc14-x86_64.dll"
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir ="c:/wamp64/tmp"

我的launch.json(C:\wamp64\www\CubePicker.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
        }
    ]
}

Settings.json:

// Place your settings in this file to overwrite the default settings
{
    "emmet.syntaxProfiles": 
    {
        "php": "html"
    },

    "php.validate.executablePath": "C:/wamp64/bin/php/php7.0.4/php.exe",

}

谁能看到我做错了什么?我在 VS Code 中启动调试器,然后通过我的浏览器运行网页,我认为这是正确的......?我怎样才能解决这个问题并让它到达我设置的断点?

如果您还需要什么,请告诉我。

谢谢!

[编辑]:我进入了 phpinfo(),找到了加载的 php.ini 的路径,并对其进行了编辑以添加第一块代码。这并没有解决问题。

[编辑]:我还在这里复制了我的整个 phpinfo():http://pastebin.com/4Jk5TuQj

【问题讨论】:

  • 如果您正在运行 php.exe,那么也将 XDEBUG 参数添加到 \wamp\bin\php\php7.0.4\php.ini。该 ini 文件控制 PHP CLI,默认情况下没有配置 XDEBUG
  • 这与 \wamp64\bin\php\php7.0.4\php.ini 有什么不同吗?如果有,它在哪里?
  • phpinfo()中列出了你需要编辑的文件,编辑后重启服务。
  • 我刚刚编辑了那个文件并添加了相同的配置,但它仍然没有达到断点...

标签: php json debugging visual-studio-code


【解决方案1】:

扩展的作者在这里。 如自述文件中所述,您需要添加

xdebug.remote_autostart = 1

到你的 php.ini,所以 XDebug 实际上会向 VS Code 发出请求。

我还搜索了您的 phpinfo() 输出,但没有 XDebug 部分。 您应该在这里使用 XDebug 配置向导:xdebug.org/wizard.php

【讨论】:

  • 我已将声明的行添加到我的 php.ini 中,但仍然没有变化。我可以用我的浏览器之类的东西浏览到文件,它可以看到路径存在。绝对是双引号,您必须将路径括起来吗?
  • 您应该在这里使用 XDebug 配置向导:xdebug.org/wizard.php
  • 非常感谢,这真的帮助了我:D
  • 我认为我做不到,因为这是评论而不是答案。
  • zend_extension="/usr/lib64/php/modules/xdebug.so" xdebug.remote_enable = 1 xdebug.remote_autostart = 1 xdebug.remote_connect_back = 1(我发现我需要所有这三个远程参数,只为下一个人)。
猜你喜欢
  • 1970-01-01
  • 2016-11-01
  • 2019-12-29
  • 1970-01-01
  • 2023-03-10
  • 2017-04-25
  • 1970-01-01
  • 1970-01-01
  • 2021-03-22
相关资源
最近更新 更多