在Docker中用PhpStormdebuggingPHP cli应用程序
我有麻烦设置debuggingPHP CLI应用程序。 我在Mac OS上工作,我在这里有Ubuntu的stream浪汉,在这个Ubuntu里面我有docker。 所以,其中一个docker容器运行我的PHP应用程序,PHP解释器居住的地方。
之前(当应用程序正好在Vagrant机器中)我使用这个命令来debugging我的cli应用程序,但现在它不工作:
export XDEBUG_CONFIG =“remote_enable = 1 remote_mode = req remote_port = 9000 remote_host = 192.168.10.10 remote_connect_back = 0”
我如何设置PhpStorm来debugging我的php cli应用程序?
Docker容器内部不使用remote_host。 此外,您不必在Docker或Vagrant中公开任何其他端口。
这是我的PHP5.6的xdebug.ini文件
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so xdebug.remote_enable=1 xdebug.remote_autostart=0 xdebug.remote_handler=dbgp xdebug.remote_port=9000 xdebug.remote_connect_back=1
确保PhpStorm (2016.1在我的情况)configuration正确
- 语言和框架 – > PHP – >服务器 – > localhost – > localhost:80 Xdebug
- 语言和框架 – > PHP – >debugging – > Xdebug – >debugging端口:9000
- 语言和框架 – > PHP – >debugging – > Xdebug – >可以接受外部连接
- 语言和框架 – > PHP – >debugging – > DBGp代理 – >端口9000
完成此操作后,在工具栏中findPhpStorm中的debugging器连接图标,然后单击它。
如果你想从命令行调用它,请记住包含XDEBUG_SESSION cookie,即
curl 'http://localhost' -sSLI -H 'Cookie: XDEBUG_SESSION=xdebug'
如果您使用Firefox安装最简单的Xdebug并在工具栏中启用它。