Vagrant + Xdebug + Atom [英] Vagrant + Xdebug + Atom

查看:28
本文介绍了Vagrant + 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.

我已经在 vagrant 文件中映射了端口 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
Atomx20H 10656 Matt   28u  IPv6 0x321cb0a96ba5b593      0t0  TCP *:cslistener (LISTEN)
VBoxHeadl 10889 Matt   19u  IPv4 0x321cb0a981a71433      0t0  TCP *:cslistener (LISTEN)

你可以看到 vagrant(虚拟盒子)和 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.

我已经在 vagrant 文件中映射了端口 9000.

I have mapped port 9000 in the vagrant file.

config.vm.network :forwarded_port,来宾:9000,主机:9000

你不需要在 Vagrant 中暴露 9000 端口——没有人会连接到它(就像你用端口 80 做 web 服务器一样)——它是来自 VM/guest OS 的 xdebug 将连接到你的真实"外部/主机操作系统.

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.

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

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