[英]xdebug in phpstorm and docker
我设法将xdebug与docker和phpstorm结合使用。 对于http呼叫... IE
http://192.168.99.100:8081/?XDEBUG_SESSION_START=PHPSTORM
但是,当我尝试运行phpunit
测试时,它无法与phpstorm连接
我在phpstorm中进行了正确的目录映射,并且还在我的export XDEBUG_CONFIG="idekey=PHPSTORM"
-instance export XDEBUG_CONFIG="idekey=PHPSTORM"
上运行了以下内容
我也在docker上尝试过:export 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
当我打开日志记录并使用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
解决方案(编辑)通过打开xdebug日志记录,我看到它成功连接到192.168.99.1
因此这解决了问题
xdebug.remote_host=192.168.99.1
我现在想到两件事:
xdebug.remote_host设置正确吗? 对于HTTP链接,您提供了192.168.
地址,回程是172.17.
地址。 您可以在该IP上ping您的主机吗?
在您的ini文件中,其内容为:
dxdebug.remote_autostart=1
这只是这里的错字,还是实际上在您的配置文件中? 因为它应该读取xdebug而不在其前面加上“ d”。 它应该是:
xdebug.remote_autostart=1
仅在执行以下脚本时添加选项时才添加d:
php -dxdebug.remote_autostart=1 script.php
如果仍然不能解决问题,请通过向配置中添加如下内容来启用远程日志:
xdebug.remote_log = /var/log/xdebug_remote.log
也许这将有助于发现问题。
对我有用的是使用此配置的ssh隧道xdebug.remote_connect_back = 0 xdebug.remote_host = 127.0.0.1
从Docker-17.06开始,您可以通过静态主机名访问Container内Mac上托管的服务: docker.for.mac.localhost
完整的答案在这里: https : //stackoverflow.com/a/48495802/1241980
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.