從瀏覽器打開頁面時,我已經能夠讓我的 PHP 腳本在 PhpStorm 中觸發我的偵聽器。我只需要在 docker 中安裝 Xdebug,并配置它xdebug.remote_connect_back = On
xdebug.remote_enable = On
xdebug.remote_autostart = Off現在我希望在從 docker 中的 PHP CLI 調用腳本時觸發它。我嘗試了幾個選項,php -dxdebug.remote_enable=1 -dxdebug.remote_autostart=1 -dxdebug.remote_connect_back=1 -dxdebug.idekey=PHPSTORM -dxdebug.remote_port=9000 myscript.php但沒有成功。我錯過了什么嗎?
2 回答

慕田峪9158850
TA貢獻1794條經驗 獲得超7個贊
從 docker 內部,腳本不知道應該將調試會話發送到哪個主機。我只需要從 docker 的 POV 中找到我的 PC ip,并將其用作主機。
找到它并ip addr尋找docker0入口,然后將其用作主機:
export PHP_IDE_CONFIG="serverName=localhost"
php -dxdebug.remote_enable=1 -dxdebug.remote_autostart=1 -dxdebug.remote_connect_back=1 -dxdebug.idekey=PHPSTORM -dxdebug.remote_port=9000 -dxdebug.remote_host=172.17.0.4 myscript.php

繁星coding
TA貢獻1797條經驗 獲得超4個贊
需要Dockerfile
有EXPOSE 9000
(打開端口:9000
)
... 否則您將無法xdebug
與外界聯系。
把IDE放到容器里是有問題的。
- 2 回答
- 0 關注
- 187 瀏覽
添加回答
舉報
0/150
提交
取消