无业游民+ Xdebug + Atom [英] Vagrant + Xdebug + Atom

查看:89
本文介绍了无业游民+ Xdebug + Atom的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装了xdebug的无所事事的盒子,可以在OSX上运行,但是我正在努力让Atom xdebug插件(php-debug)连接到它.

I have a vagrant box with xdebug installed, running on OSX, but Im struggling to get the Atom xdebug plugin (php-debug) to connect to it.

我将phpinfo();数据粘贴到xdebug验证站点中,它说一切都很好.您可以看到所有xdebug设置.

I pasted the phpinfo(); data into the xdebug validation site and it said all was good. And you can see all the xdebug settings.

我已在流浪者文件中映射了端口9000.

I have mapped port 9000 in the vagrant file.

config.vm.network :forwarded_port, guest: 9000, host: 9000

无所事事的盒子只有主机网络,该网络将192.168.10.100公开为服务器的IP.

The vagrant box has host only network that exposes 192.168.10.100 as the IP of the server.

并且我尝试了各种不同的xdebug选项,ATOM插件网站上的建议..

And I've tried all manner of different xdebug options, the ones on the ATOM plugin site suggest..

xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true

但这有点令人困惑,因为remote_connect_back=1意味着xdebug将忽略remote_host设置-因此不确定为什么两者都在其中-均无效.

But that is a slightly confusing as remote_connect_back=1 means xdebug will ignore the remote_host setting - so not sure why both are in there - neither work.

每次更改选项后,我都会重新启动apache/php,并检查它们是否已加载phpinfo();

I've restarted apache / php after each time I change the options, and check they are loaded with phpinfo();

如果我检查谁在端口9000上监听

If I check who is listening on port 9000

COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
Atom\x20H 10656 Matt   28u  IPv6 0x321cb0a96ba5b593      0t0  TCP *:cslistener (LISTEN)
VBoxHeadl 10889 Matt   19u  IPv4 0x321cb0a981a71433      0t0  TCP *:cslistener (LISTEN)

您可以同时看到无业游民(虚拟框)和Atom.尽管Atom是IPv6,这很奇怪....

You can see both vagrant (virtual box) and Atom. Although Atom is IPv6 which is odd....

但是在ATOM中启用调试器,设置断点并访问该站点,什么都没发生-ATOM从不连接.

But enabling the debugger in ATOM, setting a breakpoint and hitting the site, nothing happens - ATOM never connects.

有什么想法吗?有人让它起作用吗?

Any ideas? Anyone got this to work?

推荐答案

但这有点令人困惑,因为remote_connect_back=1意味着xdebug将忽略remote_host设置

But that is a slightly confusing as remote_connect_back=1 means xdebug will ignore the remote_host setting

您是正确的-那里不需要该选项-最好将其设置为0

You are correct -- that option is not needed there -- it better be set to 0

xdebug.remote_host = 127.0.0.1

xdebug.remote_host=127.0.0.1

这是错误的(除非您将通过SSH隧道进行调试).它必须是运行调试客户端(在您的情况下为Atom)的IP. xdebug连接到客户端,而不是其他方式: https://xdebug.org/docs/remote

This is wrong (unless you will be doing debugging via SSH tunnel). It must be an IP where debug client (Atom in your case) is running. It's xdebug who connects to client and NOT other way around: https://xdebug.org/docs/remote

这也意味着该IP必须与从该Vagrant计算机上看到的相同.可能是获得它的最简单方法-看看$_SERVER['REMOTE_ADDR']有什么.

This also means that the IP must be as seen from that Vagrant machine. Possibly the easiest way of getting it -- look at what $_SERVER['REMOTE_ADDR'] has.

我已在流浪者文件中映射了端口9000.

I have mapped port 9000 in the vagrant file.

config.vm.network :forwarded_port, guest: 9000, host: 9000

您不需要在Vagrant中公开9000端口-没有人会连接到它(就像您对Web服务器的端口80所做的那样)-来自VM/guest OS的xdebug将在外部连接到您的真实"端口/host操作系统.

You do not need to expose 9000 port in Vagrant -- nobody will be connecting to it (like you do with port 80 for web server) -- it's xdebug from VM/guest OS will be connecting outside to your "real"/host OS.

如果有的话-您应该允许该端口上的传出连接,而不是传入的.

If anything -- you should be allowing outgoing connections on that port instead of incoming.

如果我检查谁在端口9000上监听

If I check who is listening on port 9000

这表示Atom无法通过TCPv4接收传入的xdebug连接.默认情况下,xdebug将尝试使用该连接(除非您在xdebug.remote_host中指定IPv6地址).

This one means that Atom is unable to receive incoming xdebug connection over TCPv4 .. which xdebug will try to use by default (unless you specify IPv6 address in xdebug.remote_host).

如果有的话-收集xdebug日志(xdebug.remote_log)并查看它尝试在何处进行连接等.

If anything -- collect xdebug log (xdebug.remote_log) and see where it tries to connect etc.

这篇关于无业游民+ Xdebug + Atom的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆