我目前正在使用 Laravel Sail 开发后端应用程序。使用 VSCode 和 WSL2(具有远程 WSL 模式的 VSCode)在 Windows 上进行开发。
后端只为前端应用提供API。我使用 Postman 来测试我的后端,并想设置 Xdebug 以便我可以在 VSCode 中进行单步调试。
似乎断点从未被捕捉到。虽然我已经设置好了
SAIL_XDEBUG_MODE=develop,debug
在我的 .env 文件中并在 VSCode launch.json 中添加配置
{
"name": "Listen for Sail Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": { "/var/www/html": "${workspaceFolder}"
},
},
谁能帮我找出问题所在?我已经检查了不同的类似帖子,但似乎没有一个能解决我的问题。我总是看到:
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port)
我使用 php:8.2, sail:1.21.2, Laravel 9.52