Xdebug 启动连接然后自动关闭
Xdebug starts the connection and than closes automatically
我正在使用 Visual Studio 代码,Xdebug 默认安装在其中,版本为 v3.x.x。
下面分享配置,
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9001,
"stopOnEntry":true,
"log": true,
"hostname": "localhost",
"pathMappings": {
"/var/www/html": "${workspaceRoot}",
"/app": "${workspaceRoot}/app"
}
}
]
}
php.ini,
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.discover_client_host=1
test.php
<?php
echo "<script>alert('Welcome');</script>";
phpinfo();
?>
现在,当我在本地主机上的端口 9001 启动调试器时(注意没有远程主机)。通过 http://localhost:9001/test.php
访问它
它在调试控制台上给出了以下注释,
新建连接1
新连接 2
它启动了,但由于某些奇怪的原因给了我两个新的连接,它们只有在我通过浏览器访问它后才会打印出来。
现在我等待 5-10 秒(同时,浏览器继续加载,但没有任何内容可见并且它仍在尝试访问 test.php)我在所有行上放置了调试器点。
10 秒后,它突然关闭了与以下评论的连接,
<- outputEvent
OutputEvent {
seq: 0,
type: 'event',
event: 'output',
body: { category: 'console', output: 'connection 2 closed\n' }
}
connection 2 closed
<- continuedEvent
ContinuedEvent {
seq: 0,
type: 'event',
event: 'continued',
body: { threadId: 2, allThreadsContinued: false }
}
<- threadEvent
ThreadEvent {
seq: 0,
type: 'event',
event: 'thread',
body: { reason: 'exited', threadId: 2 }
}
<- outputEvent
OutputEvent {
seq: 0,
type: 'event',
event: 'output',
body: { category: 'stderr', output: 'connection closed\n' }
}
**connection closed**
我到处都查过了,但找不到我的问题的答案。请求帮助
我终于能够在 XAMPP 服务器上使用 Visual Studio 代码启动 Xdebug。我正在分享我的解决方案,以便其他人不会遇到类似问题。
在 Ubuntu
上安装 XAMPP
将其配置为将其路由到 htdocs 文件夹之外的代码
关注这个link,https://askubuntu.com/questions/64095/change-xampps-htdocs-web-root-folder-to-another-one
创建 index.php 文件和 运行,
php信息();
打开浏览器并执行localhost/index.php
-
结果将是一个包含指令列表的页面,只需一个一个地按照它们并确保 Xdebug 已成功安装在 Ubuntu
现在是重要的部分,打开文件 /opt/lampp/etc/php.ini(我正在尝试配置我的本地 Laravel php.ini 在我的代码中,这就是它无法识别的地方)
并粘贴以下命令,
xdebug.mode=调试
xdebug.start_with_request=是
xdebug.client_port=9003
xdebug.client_host = 本地主机
zend_extension = "/opt/lampp/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so"
现在开始 Visual Studio 代码并打开 index.php
上的应用调试器点
如果 运行ning 和调试尚未配置(未创建 launch.json),VS Code 将显示,您可以通过 运行宁。保留 launch.json 设置默认值。
转到 运行 --> 开始调试 -> “Listen for Xdebug” 并为 PHP 首次配置。
就是这样!
我正在使用 Visual Studio 代码,Xdebug 默认安装在其中,版本为 v3.x.x。
下面分享配置,
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9001,
"stopOnEntry":true,
"log": true,
"hostname": "localhost",
"pathMappings": {
"/var/www/html": "${workspaceRoot}",
"/app": "${workspaceRoot}/app"
}
}
]
}
php.ini,
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.discover_client_host=1
test.php
<?php
echo "<script>alert('Welcome');</script>";
phpinfo();
?>
现在,当我在本地主机上的端口 9001 启动调试器时(注意没有远程主机)。通过 http://localhost:9001/test.php
它在调试控制台上给出了以下注释,
新建连接1 新连接 2
它启动了,但由于某些奇怪的原因给了我两个新的连接,它们只有在我通过浏览器访问它后才会打印出来。
现在我等待 5-10 秒(同时,浏览器继续加载,但没有任何内容可见并且它仍在尝试访问 test.php)我在所有行上放置了调试器点。
10 秒后,它突然关闭了与以下评论的连接,
<- outputEvent
OutputEvent {
seq: 0,
type: 'event',
event: 'output',
body: { category: 'console', output: 'connection 2 closed\n' }
}
connection 2 closed
<- continuedEvent
ContinuedEvent {
seq: 0,
type: 'event',
event: 'continued',
body: { threadId: 2, allThreadsContinued: false }
}
<- threadEvent
ThreadEvent {
seq: 0,
type: 'event',
event: 'thread',
body: { reason: 'exited', threadId: 2 }
}
<- outputEvent
OutputEvent {
seq: 0,
type: 'event',
event: 'output',
body: { category: 'stderr', output: 'connection closed\n' }
}
**connection closed**
我到处都查过了,但找不到我的问题的答案。请求帮助
我终于能够在 XAMPP 服务器上使用 Visual Studio 代码启动 Xdebug。我正在分享我的解决方案,以便其他人不会遇到类似问题。
在 Ubuntu
上安装 XAMPP将其配置为将其路由到 htdocs 文件夹之外的代码 关注这个link,https://askubuntu.com/questions/64095/change-xampps-htdocs-web-root-folder-to-another-one
创建 index.php 文件和 运行, php信息();
打开浏览器并执行localhost/index.php
结果将是一个包含指令列表的页面,只需一个一个地按照它们并确保 Xdebug 已成功安装在 Ubuntu
现在是重要的部分,打开文件 /opt/lampp/etc/php.ini(我正在尝试配置我的本地 Laravel php.ini 在我的代码中,这就是它无法识别的地方) 并粘贴以下命令,
xdebug.mode=调试
xdebug.start_with_request=是
xdebug.client_port=9003
xdebug.client_host = 本地主机
zend_extension = "/opt/lampp/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so"
现在开始 Visual Studio 代码并打开 index.php
上的应用调试器点如果 运行ning 和调试尚未配置(未创建 launch.json),VS Code 将显示,您可以通过 运行宁。保留 launch.json 设置默认值。
转到 运行 --> 开始调试 -> “Listen for Xdebug” 并为 PHP 首次配置。
就是这样!