php - VS Code launch.json Xdebug 配置,用于在 Windows Server 8 中逐步调试 PHP 页面
问题描述
我在 Windows Server 8 上有一个 PHP 项目,我希望能够使用 VS Code 中的这些页面并进行分步调试,但我不知道如何正确配置 launch.json。
我在 Windows Server 上安装了 Xdebug 3 并且它处于活动状态。我输入的配置php.ini
是这样的:
[XDebug]
zend_extension = xdebug
xdebug.mode= debug, develop
xdebug.start_with_request=yes
xdebug.idekey=VSCODE
xdebug.remote_port = 9003
xdebug.discover_client_host = true
xdebug.client_discovery_header = HTTP_XDEBUG_IP
xdebug.show_exception_trace = 1
xdebug.connect_timeout_ms = 5000
考虑到:
“11.128.7.124:3555”是 Apache 在该服务器上使用的 IP Windows 服务器和端口。
我从 VS Code 打开服务器 PHP 文件夹,抛出一个网络单元。
在 Windows 8 服务器中安装了 XAMPP 和 PHP 7.2
我已经阅读了很多信息,但是我已经能够配置环境来执行我在本地打开该项目时可以执行的步骤调试。
我还在 Microsoft Edge 和 Google Chrome 浏览器(活动)中安装了 Xdebug 扩展。
VS Code 上的launch.json
文件有这样的配置(没有相同的 IP 地址和端口):
{
// 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": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"11.128.7.124:3555"
],
"program": "",
"cwd": "${fileDirname}",
"port": 9003,
"pathMappings": {
"d:/xampp/htdocs/myproject": "${workspaceFolder}/htdocs",
"/myproject": "${workspaceFolder}"
},
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003
}
]
}
这是xdebug_info()
函数输出:
解决方案
我认为你的问题是:
xdebug.remote_port = 9003
该设置已在 Xdebug 3 中重命名为xdebug.client_port
( https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_port )。
或者,您可以修改launch.json
,以便它还将端口port
设置为“启动内置 Web 服务器”案例中相同启动配置的设置。
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-dxdebug.client_port=${port}",
"-S",
"11.128.7.124:3555"
],
提示
为了调试 Xdebug 调试的问题,您可以xdebug_info()
在您尝试调试的脚本中使用新的 Xdebug 3 函数,它会向您显示正在发生的事情、Xdebug 尝试过的内容以及它是否可以连接到调试器等。
推荐阅读
- http - HTTP Keep Alive 会减少 TLS 连接吗?
- aws-lambda - 从 Lambda 内部运行 databrew.describe_job_run() 不起作用
- rundeck - 按时间限制重试,而不是尝试
- javascript - 在 react.js 中使用按钮同时发送表单和 href
- html - 如何在卡片中插入行/列(使用 v-for)?
- terminal - 终端在 JupyterLab Launcher 中不可用
- c++ - 关于 Sentinel 循环 C++ 的建议
- java - 同一个包中的两个类不能一起工作
- python - .aspx 网站网页抓取使用 python
- reactjs - How do I render the following code in the render function?