Xdebug-从docker内部触发PhpStorm中的调试

Xdebug-从docker内部触发PhpStorm中的调试,php,docker,debugging,phpstorm,xdebug,Php,Docker,Debugging,Phpstorm,Xdebug,我已经能够让我的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

我已经能够让我的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,但没有成功。我遗漏了什么吗?

Dockerfile需要打开端口:9000

。。。否则,您将无法从外部世界连接xdebug


将IDE放入容器是有问题的。

因此,感谢@LazyOne的评论,我得到了答案。从docker内部,脚本不知道应该将调试会话发送到哪个主机。我只需要从docker的POV中找到我的PC ip,并将其用作主机

使用ip地址找到它并查找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

为什么?是Xdebug连接到IDE,而不是其他方式…它以两种方式工作。。。本地防火墙旁边可能会阻止:9000。如果Docker使用TCP 9000端口进行传入连接。。然后IDE将无法在该端口上侦听…IDE不应放入容器中-因此它必须从外部连接。在某些情况下,这可能是有用的,但它只会使容器图像膨胀。实际上是xdebug在运行时正在监听:9000,否则不行。实际上是xdebug在运行时正在监听:9000,否则不行。请在做出此类声明之前检查xdebug文档,特别是通信设置部分:请检查