VSCodium (VSCode) 不启动调试 PHP (PHP Debug + Xdebug, Linux)
VSCodium (VSCode) doesn't start debugging PHP (PHP Debug + Xdebug, Linux)
目标
使用 PHP Debug、Xdebug 和 VSCodium 进行调试。
问题
VSCode 没有开始调试。当我单击 Start Debugging
时,调试控制按钮下方的蓝线出现并移动几秒钟,然后控制按钮消失。当我按下绿色“运行”按钮时也是如此
同样在左侧,“变量”、“观察”和“堆栈”都没有显示。
描述
我没有使用 VSCodium 调试选项的经验。我使用了几个教程(1, 2, 3、视频,并尝试了来自 VSCode PHP 调试扩展站点(我使用的)的建议。
我在 Linux Mint 20 机器上使用 Codium (VSCode without MS)。 PHP 7.4 和 Xdebug 通过 Linux Synaptic Package Manager 安装。当然,Firefox 中的 Xdebug 助手已启用,断点已设置,我在不同的项目中进行了尝试。我在 php.ini
中尝试了一些东西。这就是它现在的样子:
[XDebug]
xdebug.remote_enable = 1
; xdebug.remote_autostart = 1
; xdebug.remote_connect_back = 1
Xdebug 本身是通过 /etc/php/7.4/cli/conf.d/20-xdebug.ini
加载的,在 PhpStorm 中它按预期工作但在 VSCodium 中不是。
就是标准的launch.json
,保存在项目根目录下的.vscode
文件夹中:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
这是我的 phpinfo()
输出的一部分:
以及 xdebug 部分:
这是我用 VSCodium 尝试时的 xdebug 日志:
[5625] Log opened at 2020-10-04 10:05:20
[5625] I: Connecting to configured address/port: localhost:9000.
[5625] W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (29).
[5625] E: Could not connect to client. :-(
[5625] Log closed at 2020-10-04 10:05:20
我的猜测是,有一个基本的 VSCodium 调试工具,我没有启用。但我不知道,它可能是什么。
也许有人有想法?
终于找到解决办法了。这是一个 Codium 特定的错误。在 VSCode 它有效。
在这里找到解决方案:
https://github.com/VSCodium/vscodium/issues/466
确保您没有安装 PHP 调试扩展;
转到https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug并使用“资源”→“下载扩展”下载 vsix 文件;
在 VSCodium 中转到“扩展”边栏,然后单击附近的三个点图标
到“扩展”标题;
选择“从 VSIX 安装...”并select 下载文件。
@LazyOne 再次感谢您的帮助:)
编辑:
如果您更新到 Xdebug 3.*,您必须修改 php.ini
中的 xdebug 部分:
添加这个:
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9000
如果您在 launch.json
中将端口更改为 9003,则可以删除最后一行。
另请参阅此 GitHub Issue
目标
使用 PHP Debug、Xdebug 和 VSCodium 进行调试。
问题
VSCode 没有开始调试。当我单击 Start Debugging
时,调试控制按钮下方的蓝线出现并移动几秒钟,然后控制按钮消失。当我按下绿色“运行”按钮时也是如此
同样在左侧,“变量”、“观察”和“堆栈”都没有显示。
描述
我没有使用 VSCodium 调试选项的经验。我使用了几个教程(1, 2, 3、视频,并尝试了来自 VSCode PHP 调试扩展站点(我使用的)的建议。
我在 Linux Mint 20 机器上使用 Codium (VSCode without MS)。 PHP 7.4 和 Xdebug 通过 Linux Synaptic Package Manager 安装。当然,Firefox 中的 Xdebug 助手已启用,断点已设置,我在不同的项目中进行了尝试。我在 php.ini
中尝试了一些东西。这就是它现在的样子:
[XDebug]
xdebug.remote_enable = 1
; xdebug.remote_autostart = 1
; xdebug.remote_connect_back = 1
Xdebug 本身是通过 /etc/php/7.4/cli/conf.d/20-xdebug.ini
加载的,在 PhpStorm 中它按预期工作但在 VSCodium 中不是。
就是标准的launch.json
,保存在项目根目录下的.vscode
文件夹中:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
这是我的 phpinfo()
输出的一部分:
以及 xdebug 部分:
这是我用 VSCodium 尝试时的 xdebug 日志:
[5625] Log opened at 2020-10-04 10:05:20
[5625] I: Connecting to configured address/port: localhost:9000.
[5625] W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (29).
[5625] E: Could not connect to client. :-(
[5625] Log closed at 2020-10-04 10:05:20
我的猜测是,有一个基本的 VSCodium 调试工具,我没有启用。但我不知道,它可能是什么。 也许有人有想法?
终于找到解决办法了。这是一个 Codium 特定的错误。在 VSCode 它有效。 在这里找到解决方案: https://github.com/VSCodium/vscodium/issues/466
确保您没有安装 PHP 调试扩展;
转到https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug并使用“资源”→“下载扩展”下载 vsix 文件;
在 VSCodium 中转到“扩展”边栏,然后单击附近的三个点图标 到“扩展”标题;
选择“从 VSIX 安装...”并select 下载文件。
@LazyOne 再次感谢您的帮助:)
编辑:
如果您更新到 Xdebug 3.*,您必须修改 php.ini
中的 xdebug 部分:
添加这个:
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9000
如果您在 launch.json
中将端口更改为 9003,则可以删除最后一行。
另请参阅此 GitHub Issue