微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我的 Xdebug 不工作为什么断点不起作用?

如何解决我的 Xdebug 不工作为什么断点不起作用?

我已经在本地安装了带有 VS Code 和 Flywheel 的 Xdebug,我正在学习如何制作主题。我在 index.PHP 文件中放置了一个断点。但是,该断点不起作用。

我的控制台没有出现任何错误。当我加载我的网站时,VS Code 调试终端中没有发生任何事情。只是一片空白。我还在 VS Code 中安装了 PHP Debug 扩展。

但是,当我在调试控制台中输入任何内容时,我收到此消息 - 无法在没有连接的情况下评估代码

这里出了什么问题?

我的 PHP.ini

[xdebug]
{{#if os.windows}}
zend_extension = PHP_xdebug.dll
{{else}}
zend_extension = {{extensions.xdebug}}
{{/if}}

xdebug.remote_enable=1
xdebug.remote_connect_back=Off
xdebug.remote_port="9000"
xdebug.profiler_enable=0
xdebug.remote_autostart = 1
xdebug.mode=debug

我的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": "Listen for XDebug","type": "PHP","request": "launch","port": 9000,"pathMappings": {
                "C:/Users/ajayb/Local Sites/wordpress-theme-1/app/public": "${workspaceRoot}"
            }
        },{
            "name": "Launch currently open script","program": "${file}","cwd": "${fileDirname}","port": 9000
        }
    ]
}

解决方法

我遇到了同样的问题。当使用 PHP 7.4 时,本地由 FlyWheel 为 PHP 7.3 和 XDebug 3.x 安装 Xdebug 2.7。如果您使用的是 PHP 7.4,请修改 php.ini.hbs 文件并将 xdebug 部分替换为以下内容:

xdebug.mode=debug
xdebug.client_port="9000" ; Default now is 9003
xdebug.start_with_request=yes

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。