Php Visual Studio代码-Xdebug赢得';行不通
在VisualStudioCode(1.9.1)(mac)中,我设置了php调试插件 在调试屏幕中,我启动“侦听Xdebug”。Php Visual Studio代码-Xdebug赢得';行不通,php,macos,xampp,visual-studio-code,xdebug,Php,Macos,Xampp,Visual Studio Code,Xdebug,在VisualStudioCode(1.9.1)(mac)中,我设置了php调试插件 在调试屏幕中,我启动“侦听Xdebug”。 在此之后,我在XAMPP服务器(本地)上打开index.php 但什么也没发生 屏幕底部的蓝色条变成橙色 “跨过”、“跨入”和“退出”按钮变灰 在监视的变量处也会出现以下错误消息: 无法计算没有连接的代码 我尝试在以下代码上使用断点: <?php $i = 0; do { $i++; if (!($i % 1)) { echo('<p>
在此之后,我在XAMPP服务器(本地)上打开index.php 但什么也没发生
- 屏幕底部的蓝色条变成橙色李>
- “跨过”、“跨入”和“退出”按钮变灰李>
- 在监视的变量处也会出现以下错误消息:
无法计算没有连接的代码
<?php
$i = 0;
do {
$i++;
if (!($i % 1)) {
echo('<p>$i = ' . $i . '</p>');
}
}
while ($i < 100);
?>
我使用自制软件安装了Xdebug。以下是我的php信息:
告诉我Xdebug安装正确 我的launch.json文件如下所示:
{
"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
}
]
}
有人知道我做错了什么吗
在ini文件中设置xdebug.remote\u connect\u back=1
后正如n00dl3所建议的那样,调试大部分时间都是有效的,但偶尔我会得到以下结果
调试控制台中出现错误:
<- threadEvent
ThreadEvent {
seq: 0,
type: 'event',
event: 'thread',
body: { reason: 'exited', threadId: 1 } }
似乎需要设置服务器根目录
在launch.json中使用localSourceRoot如下所示:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"localSourceRoot": "http://127.0.0.1/public_html/"
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
现在断点正在正常工作。我也遇到了这个问题,不是在相同的环境中(NGINX服务器+php fpm
),而是在相同的症状下。结果证明这是由我的xdebug
配置引起的
我是如何诊断它的:通过编写一个简单的PHP脚本进行测试,就像OP所做的那样:
检查xdebug.client\u端口
在第xdebug_info()页;或phpinfo()
在vscode的launch.json中配置相同的端口我也遇到了这个问题
不知何故,有一天,我在没有意识到的情况下安装了xdebug的版本3,并且更改了很多conf参数名称,请参见
因此,以phpinfo为例验证xdebug版本是值得一试的。您是否尝试在ini文件中设置xdebug.remote\u connect\u back=1
?它现在似乎大部分时间都可以工作,但偶尔我会在调试控制台中遇到以下错误:`不知道这一点
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"localSourceRoot": "http://127.0.0.1/public_html/"
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
xdebug.client_host => localhost
xdebug.client_port => 9003
# This should match your xdebug.remote_host
xdebug.client_host=localhost
# This should match your xdebug.remote_port
xdebug.client_port=9900
xdebug.mode=debug