【发布时间】:2021-05-17 07:32:44
【问题描述】:
Web 上大多数使用 VSCode 和 WSL 进行 PHP 调试的示例都使用 Xdebug 2.x php.ini 设置。这些不再适用于 3.0 版。有关更改的详细信息,请参阅Xdebug Upgrade。
以下内容适用于我的一个 PHP 项目,其中包含一个文件,只是为了测试调试。使用 Ubuntu 20.04、WSL2、Xdebug 3.02 以及 Felix Becker 的 VSCode 扩展 Remote WSL 和 PHP Debug。
我必须在我的系统上同时修改 /etc/php/7.3/apache2/php.ini 和 /etc/php/7.3/cli/php.ini。希望这对你们有用。
php.ini
[xdebug]
zend_extension = ./lib/php/20180731/xdebug.so
xdebug.start_with_request = trigger
xdebug.mode = debug
xdebug.discover_client_host = 1
xdebug.log = /tmp/xdebug_remote.log
xdebug.client_port = 9003
launch.json
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003,
"stopOnEntry": true,
"log": true,
"pathMappings":
{
"/var/www/html/test": "${workspaceRoot}"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003
}
]
【问题讨论】:
标签: visual-studio-code xdebug vscode-remote