您的设置是 xdebug v2 的设置,但看起来您使用的是 xdebug v3。
正如 Derick 在 cmets 中提到的,有一个 upgrade guide。
根据我的经验,在我完成一些配置后,我主要了解这些手册,
因为这不仅取决于 xdebug,还取决于 IDE 的配置以及如何映射
您的服务器文件夹到您的本地项目文件夹。
因此,让我展示两种工作配置,一种使用 netbeans,一种使用 vscode。
我的设置如下:
我的 projectdir 映射到服务器如下:
local: /`projectdir`/site/public
to server: /var/www/site/public (This is DocumentRoot in the apache configuration file)
index.php is located in /`projectdir`/site/public
将projectdir 替换为您的项目目录。
在 Windows 上,用反斜杠替换正斜杠。
为您的配置使用正确的 zend_extension 路径。
-
使用 netbeans 进行配置
php.ini:
zend_extension=xdebug.so
xdebug.mode = 调试
xdebug.discover_client_host = true
xdebug.idekey="netbeans-xdebug"
netbeans 中的调试配置(工具 > 选项 > PHP > 调试):
Debugger Port: 9003
Session ID: netbeans-xdebug
(and maybe check Stop at First Line)
netbeans中的项目属性(右键项目>属性):
Sources: Project Folder: <project>
Source Folder: <project>
Web Root: site/public
Run Configuration: Project URL: <URL> (or hostname)
Index File: index.php
xdebug 的默认端口已更改为 9003;您可以在 php.ini 中使用 xdebug.client_port 将其设置为 9000。
xdebug.discover_client_host 将尝试连接到您的 IDE。如果这不起作用,您可以尝试使用 xdebug.client_host 设置客户端的 IP 地址,从而替换版本 2 中的 xdebug.remote_host。
显然xdebug.idekey 必须与你的netbeans 配置的Session ID 相对应。
-
使用 vscode 进行配置
php.ini:
zend_extension=xdebug.so
xdebug.mode = 调试
xdebug.start_with_request = 是
xdebug.discover_client_host = true
.vscode/launch.json(菜单:运行>添加配置...)
{
// 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": "Listen for XDebug 3",
"type": "php",
"request": "launch",
"stopOnEntry": true,
"pathMappings": {
"/var/www": "${workspaceRoot}",
},
"port": 9003
},
{
"name": "Listen for XDebug 2",
"type": "php",
"request": "launch",
"stopOnEntry": true,
"pathMappings": {
"/var/www": "${workspaceRoot}",
},
"port": 9000
}
]
}