使用VScode和Xdebug调试php文件

问题描述

我正在尝试在VScode上使用Xdebug,我已经阅读了很多有关它的文章,但也许​​它们不适合我的情况。我在Linux OpenSuse上,这是我所做的:

首先,我安装了PHP7-xdebug,并修改了/etc/PHP7/cli/PHP.ini和/etc/PHP7/conf.d/PHP.ini并添加

zend_extension="/usr/lib64/PHP7/extensions/xdebug.so
xdebug.remote_autorestart=1
xdebug.remote_autostart=1
xdebug.remote_log=/var/log/xdebug.log
xdebug.remote_port = 9009
xdebug.idekey = VSCODE

在VSCode中,我安装了PHP调试扩展,打开了我的Web文件夹(我用于www文件文件夹),并创建了一个配置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": 9009
        },{
            "name": "Launch currently open script","program": "${file}","cwd": "${fileDirname}","port": 9000
        }
    ]
}

然后sudo systemctl启动Nginx,sudo systemctl启动PHP-fpm,在示例代码中放置了断点。之后,我在左侧选择了Lisen作为XDebug并按下了播放键。什么也没发生,只有vscode的底部变成红色,没有消息,没有写任何地方(我可以看到)。 如果我尝试在调试控制台中写东西,答案是Cannot evaluate code without a connection

有人可以帮助我进行配置吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)