Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker + xdebug + PHPStorm #260

Open
2 tasks done
qiuyimo opened this issue Mar 17, 2018 · 8 comments
Open
2 tasks done

Docker + xdebug + PHPStorm #260

qiuyimo opened this issue Mar 17, 2018 · 8 comments

Comments

@qiuyimo
Copy link

qiuyimo commented Mar 17, 2018

操作系统

  • macOS

Docker 版本

  • Stable (v17.12)

问题描述

环境说明

clone 本项目.
执行的是 ./lnmp-docker.sh development 安装.
安装完毕把 bin 加入了环境变量中.

问题

  • docker-php -m 中没有 xdebug 扩展?
    image

  • docker-php -ini 中没有指定 php.ini 文件? 是否是这个的原因?
    image

  • 网页中打印的 phpinfo(), 可以看到是有 xdebug 的. 并且也指定了 php.ini
    image
    image

我是想在 phpstorm 中使用 docker 的环境. 但是解析不出 xdebug.

image

@khs1994
Copy link
Member

khs1994 commented Mar 17, 2018

lnmp-php 命令没有载入 xdebug.ini,所以命令行模式没有 xdebug 扩展。

@khs1994
Copy link
Member

khs1994 commented Mar 17, 2018

按这个文档,你试试浏览器调试

@khs1994
Copy link
Member

khs1994 commented Mar 18, 2018

最后一张图里,你可以在 Additional->Debugger extension 里填 xdebug,之后刷新,就看到 xdebug 启用了

@khs1994 khs1994 changed the title [请求帮助] docker-php -m 中没有xdebug扩展. Docker + xdebug + PHPStorm 讨论 Mar 18, 2018
khs1994 added a commit that referenced this issue Mar 18, 2018
@khs1994
Copy link
Member

khs1994 commented Mar 18, 2018

浏览器调试能实现吗?

你不设置 DNS 的话,xdebug 设置成这样

xdebug.remote_host=host.docker.internal

@khs1994
Copy link
Member

khs1994 commented Mar 18, 2018

下面记录一下以下参数对 xdebug 的影响

  • xdebug.remote_host=192.168.199.101 我电脑实际 IP 为 192.168.199.100,这里故意设置错

  • xdebug.remote_connect_back=0 不启用,意思是不忽略 host 设置

日志如下 logs/php-fpm/xdebug-remote.log

Log opened at 2018-03-18 07:02:41
I: Connecting to configured address/port: 192.168.199.101:9001.
E: Time-out connecting to client (Waited: 200 ms). :-(
Log closed at 2018-03-18 07:02:41

连接超时,原因不用说了吧

@khs1994
Copy link
Member

khs1994 commented Mar 18, 2018

  • xdebug.remote_host=192.168.199.101 我电脑实际 IP 为 192.168.199.100,这里故意设置错

  • xdebug.remote_connect_back=1 启用,意思是忽略 host 设置

日志如下 logs/php-fpm/xdebug-remote.log

Log opened at 2018-03-18 07:07:30
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 172.19.0.1:9001.
W: Creating socket for '172.19.0.1:9001', poll success, but error: Operation in progress (29).
E: Could not connect to client. :-(
Log closed at 2018-03-18 07:07:30

看样子忽略 host 设置,xdebug 会从 http 请求头信息中解析客户端地址,很明显,解析到的是 docker 内部地址,所以还是连接不上!

@khs1994
Copy link
Member

khs1994 commented Mar 18, 2018

  • xdebug.remote_host=192.168.199.100 我电脑实际 IP 为 192.168.199.100,这里设置正确

  • xdebug.remote_connect_back=0 不启用,意思是不忽略 host 设置(经过上一步,知道为什么不能设置为 1)

日志如下 logs/php-fpm/xdebug-remote.log

日志内容不告诉你,猜猜什么结果?成功还是出现错误提示

@khs1994
Copy link
Member

khs1994 commented Mar 18, 2018

  • xdebug.remote_host=host.docker.internal 千万不能设置 Docker 中的 DNS 选项

  • xdebug.remote_connect_back=0 不启用,意思是不忽略 host 设置(经过上一步,知道为什么不能设置为 1)

日志如下 logs/php-fpm/xdebug-remote.log

日志内容还是不告诉你,猜猜什么结果?成功还是出现错误提示

@khs1994-docker khs1994-docker deleted a comment from qiuyimo Mar 18, 2018
@khs1994-docker khs1994-docker deleted a comment from qiuyimo Mar 18, 2018
@khs1994-docker khs1994-docker deleted a comment from qiuyimo Mar 18, 2018
@khs1994-docker khs1994-docker deleted a comment from qiuyimo Mar 18, 2018
@khs1994-docker khs1994-docker deleted a comment from qiuyimo Mar 18, 2018
@khs1994-docker khs1994-docker deleted a comment from qiuyimo Mar 18, 2018
@khs1994-docker khs1994-docker deleted a comment from qiuyimo Mar 21, 2018
@khs1994-docker khs1994-docker deleted a comment from qiuyimo Mar 21, 2018
@khs1994-docker khs1994-docker deleted a comment from qiuyimo Mar 21, 2018
@khs1994-docker khs1994-docker deleted a comment from qiuyimo Mar 21, 2018
@khs1994 khs1994 changed the title Docker + xdebug + PHPStorm 讨论 Docker + xdebug + PHPStorm Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants