2 回答

TA貢獻1796條經驗 獲得超10個贊
不要使用運行/調試配置進行 Web 調試,這會適得其反。您可以使用零配置調試直接從瀏覽器啟動調試連接。
禁用
xdebug.remote_connect_back
,弊大于利,尤其是 Docker。xdebug.remote_host
不應該localhost
在您使用 Docker 時出現,這樣,容器會嘗試將調試數據發送給自身而不是主機。看來您使用的是 macOS 和 Docker for Mac,host.docker.internal
在這種情況下應該是正確的主機名。如果從瀏覽器啟動調試會話后 PhpStorm 仍然無法捕獲連接,我們將需要按照@LazyOne 的建議查看 Xdebug 日志。

TA貢獻1784條經驗 獲得超7個贊
我使用了這個設置并且它有效:)
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.default_enable=1
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.profiler_enable=0
xdebug.profiler_output_dir="/var/www/html"
xdebug.var_display_max_depth=20
xdebug.remote_host=host.docker.internal
xdebug.remote_enable=1
xdebug.remote_connect_back=0
在 vscode 中使用 launch.json
"name": "Listen 9000",
"type": "php",
"request": "launch",
"log": true,
"externalConsole": false,
"pathMappings": {
"/var/www/html": "/Users/folder/project/src"
},
"port": 9000,
使用 docker-compose.yml:
- 2 回答
- 0 關注
- 154 瀏覽
添加回答
舉報