【发布时间】:2021-12-25 17:55:36
【问题描述】:
我在 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()函数输出:
【问题讨论】:
标签: php xdebug remote-debugging vscode-debugger vscode-remote