在phpstorm和docker中的xdebug

Con*_*nce 5 php xdebug phpstorm docker

我设法将xdebug与docker和phpstorm结合使用.对于http调用... IE

http://192.168.99.100:8081/?XDEBUG_SESSION_START=PHPSTORM

但是当我尝试运行我的phpunit测试时,它没有与phpstorm连接

我在phpstorm中执行了正确的目录映射,并在docker-instance上运行了以下命令 export XDEBUG_CONFIG="idekey=PHPSTORM"

我也试过我的docker:导出PHP_IDE_CONFIG ='serverName = web.docker'并在phpstorm web.docker上命名服务器配置.仍然在http而不是CLI上工作

那么我可以将phpstorm和xdebug一起用于命令行吗?

这是我的档案: /etc/php5/cli/conf.d/20-xdebug.ini

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_connect_back=1
xdebug.remote_host=172.17.42.1
dxdebug.remote_autostart=1
Run Code Online (Sandbox Code Playgroud)

当我打开日志记录,并使用xdebug_remote_host IP地址时,我得到了

W: Remote address not found, connecting to configured address/port: localhost:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:20:39

Log opened at 2015-10-13 12:22:58
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 172.17.42.1:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:22:58

Log opened at 2015-10-13 12:23:58
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 192.168.99.100:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:23:58
Run Code Online (Sandbox Code Playgroud)

解决方案(编辑) 通过打开xdebug日志记录,我看到它已成功连接,192.168.99.1因此解决了这个问题

xdebug.remote_host=192.168.99.1
Run Code Online (Sandbox Code Playgroud)

Pam*_*mpy 4

我现在想到两件事:

  1. xdebug.remote_host 设置正确吗?对于 HTTP 链接,您提供了一个192.168.地址,对于返回的方式,它是一个172.17.地址。你能在该 IP 上 ping 通你的主机吗?

  2. 在你的 ini 文件中它是这样的:

    dxdebug.remote_autostart=1
    
    Run Code Online (Sandbox Code Playgroud)

    这只是这里的拼写错误,还是实际上在您的配置文件中?因为它应该读取前面没有“d”的 xdebug。它应该是:

    xdebug.remote_autostart=1
    
    Run Code Online (Sandbox Code Playgroud)

    您应该只在执行脚本时添加选项时添加 d,如下所示:

    php -dxdebug.remote_autostart=1 script.php
    
    Run Code Online (Sandbox Code Playgroud)

如果这还没有帮助,请通过在配置中添加如下内容来启用远程日志:

xdebug.remote_log = /var/log/xdebug_remote.log
Run Code Online (Sandbox Code Playgroud)

也许这将有助于找到问题。