简体   繁体   English

Xdebug 连接不适用于 PhpStorm 和 Docker

[英]Xdebug connection not working with PhpStorm and Docker

I have a problem debugging PHP with PhpStorm.我在使用 PhpStorm 调试 PHP 时遇到问题。 I have container, and it is running Ubuntu 18.04.2 LTS and my host machine is macOS 10.14.5.我有容器,它正在运行 Ubuntu 18.04.2 LTS,我的主机是 macOS 10.14.5。 I added configuration to PhpStorm, but breakpoint is not hit.我向 PhpStorm 添加了配置,但没有命中断点。

So, this is my xdebug.ini configuration:所以,这是我的 xdebug.ini 配置:

zend_extension=xdebug.so
xdebug.max_nesting_level = 250
xdebug.remote_port = 9000
xdebug.idekey = "XDEBUG_ECLIPSE"
xdebug.remote_host = "192.168.1.144"
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
xdebug.var_display_max_depth = -1

#  Enable the debugging on request
xdebug.remote_enable = on
xdebug.remote_autostart = off

# enable logging
xdebug.remote_log=/tmp/xdebug.log

When I run php -m -v , I can see under Zend Modules that Xdebug is enabled/installed.当我运行php -m -v时,我可以在 Zend Modules 下看到 Xdebug 已启用/安装。 My php version is PHP 7.1.32.我的 php 版本是 PHP 7.1.32。

192.168.1.144 is the IP of my host machine. 192.168.1.144 是我的主机的 IP。 I also checked that PhpStorm is configured to listen on port 9000我还检查了 PhpStorm 是否配置为侦听端口 9000

Xdebug 设置

When I created new configuration, I set IDE key(session id) as XDEBUG_ECLIPSE , also, when I defined server under configuration, host is correct (dummy.test), port is set to 80, and Debugger is set to Xdebug.当我创建新配置时,我将IDE key(session id)设置为XDEBUG_ECLIPSE ,另外,当我在配置下定义服务器时,主机是正确的(dummy.test),端口设置为 80,调试器设置为 Xdebug。

I also ran command tail -f /tmp/xdebug.log , and when I refreshed the page, there wasn't any new entry in the log file.我还运行了命令tail -f /tmp/xdebug.log ,当我刷新页面时,日志文件中没有任何新条目。

Any idea what am I missing?知道我错过了什么吗? I set up breakpoint to one index function of xy controller and is not hit, I also enabled break at first line in PHP script.我将断点设置到 xy controller 的一个索引 function 并且没有被命中,我还在 PHP 脚本的第一行启用了断点。

phpinfo

so, with help of the topic owner it was found that for Mac host.docker.internal is set doc因此,在主题所有者的帮助下,发现对于 Mac host.docker.internal是设置文档

as a hack-solution host ip was added to /etc/hosts inside docker container: host-ip host.docker.internal作为黑客解决方案主机 ip 被添加到 docker 容器内的/etc/hosts中: host-ip host.docker.internal

probably there should be a better solution:)可能应该有更好的解决方案:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM