PHP远程调试:XDebug无法连接JetBrains php Storm客户端 [英] PHP remote debugging: XDebug can't connect to JetBrains php Storm client

查看:36
本文介绍了PHP远程调试:XDebug无法连接JetBrains php Storm客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢使用以下软件配置进行远程调试:

i's like to get remote debugging to work with the following software configuration:

Win 7 Pro 64 位WAMP 服务器 2.2(32 位)包括.Apache 2.2.22、PHP 5.4.3、XDebug php_xdebug-2.2.1-5.4-vc9.dllJetBrains PHPStorm 4.0.3

Win 7 Pro 64bit WAMP Server 2.2 (32bit) incl. Apache 2.2.22, PHP 5.4.3, XDebug php_xdebug-2.2.1-5.4-vc9.dll JetBrains PHPStorm 4.0.3

1.) WAMP 启动并运行,我的站点可以在 localhost/fox/下找到

1.) WAMP is up and running, my site can be found under localhost/fox/

2.) PHP Storm 有一个项目,其中我的源文件和 apache 别名 localhost/fox 之间存在映射

2.) PHP Storm has a project where there is a mapping between my sourcefiles and the apache alias localhost/fox

2.) 我安装了 php 扩展 XDebug 并将以下几行添加到我的 php.ini

2.) I installed the php extension XDebug and added the following lines to my php.ini

[xdebug]
zend_extension="c:/wamp/bin/php/php5.4.3/zend_ext/php_xdebug-2.2.1-5.4-vc9.dll"
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_connect_back=On
xdebug.remote_autostart=On
xdebug.profiler_enable=On
xdebug.profiler_enable_trigger=off
xdebug.profiler_output_name=cachegrind.out.%t.%p
xdebug.profiler_output_dir="c:/wamp/tmp"
xdebug.remote_log="C:/wamp/tmp/xdebug.log"
xdebug.remote_cookie_expire_time=6000

这应该配置远程调试 XDebug 和回调地址.

This should configure the Remote Debugging XDebug and the call back address.

我已经在这里检查了我的安装:xdebug.org/wizard.php

I check already my installation here: xdebug.org/wizard.php

3.) 我配置了 phpstorm,首先我添加了本地服务器

3.) I configured phpstorm, first i added the local server

然后在这里检查我的设置

and then checked my settings here

http://www.bilder-hochladen.net/files/jrn0-2-c81e-jpg-nb.html

(我也尝试将 127.0.0.1/fox 作为服务器地址,而使用 localhost)

( i tried 127.0.0.1/fox as Server address as well, and localhost instead)

hier 我的调试设置:http://www.bilder-hochladen.net/files/jrn0-1-c4ca-jpg.html

hier my debug settings: http://www.bilder-hochladen.net/files/jrn0-1-c4ca-jpg.html

现在我重新启动我的apache,我进入phpstorm,设置一个断点(它是红色的),点击功能

Now i restart my apache, i go into phpstorm, set a break point (it is red), click the function

Run  -> Start listen to PHP Debug Connections

电话听筒变成绿色,这究竟意味着什么,但对我来说这是一个积极的信号.

The telephone receiver is turing into green, what ever that exactly could mean but it's a positiv signal to me.

当我现在在本地网络服务器上运行我的 php 脚本时绝对没有任何反应,程序运行在断点上并且不会停止.

When I now run my php Script on the local webserver absolutley nothing happens, the programm runs over the break point and does not stop.

在 Xdebuggers 日志 (C:/wamp/tmp/xdebug.log) 中,我发现这些消息的负载如下:

In the Xdebuggers log (C:/wamp/tmp/xdebug.log) i find loads of these messages like these:

 I: Checking remote connect back address.
 I: Remote address found, connecting to ::1:9000.
 E: Could not connect to client. :-(
 Log closed at 2012-07-19 14:21:08

我在互联网的某个地方发现了一个提示,Windows 防火墙可能会阻止通信,所以我将其完全关闭,但这并没有帮助.

Somewhere in the internet i found the hint, that the windows firewall could block the communication so i turned it off completley but that did not help.

我还尝试通过 telnet 连接到 localhost:9000,但我收到了来自 phpstorm 的响应.

I also tried to connect via telnet to localhost:9000 and i got a response from phpstorm.

有没有人知道在哪里搜索错误或我可以尝试让这些东西正常工作?

Has anybody an idea where to search the error or what else i could try to get this stuff working ?

非常感谢您提前提供的帮助,迈克尔

Thank you very much for your help in advance, Michael

附言抱歉,我不允许发布两个以上的链接,因为我是新来的,因此没有指向 xdebug 向导的超链接.

p.s. Sorry i am not allowed to post more than two links because I am new here, so therefor no hyperlink to the xdebug wizard.

推荐答案

可能有点晚但是...

这里你的设置有矛盾:

xdebug.remote_host="localhost"
xdebug.remote_connect_back=On

这两个设置重叠.你的情况是什么?

Those two settings overlap. What is your case?

a) 您只想从一个源调试应用程序(例如,您正在从 localhost 进行开发和部署).

a) You want to debug your application just from one single origin (for example, you are developing from and deploying to localhost).

那么你就快完成了:你已经定义了远程主机是localhost.注释掉 remote_connect_back 行(使用 ;)

Then you are almost done: you have already defined that the remote host is localhost. Comment out the remote_connect_back line (with ;)

b) 您希望接受多个开发源(例如,在同一网络中调试应用程序的多台机器).

b) You want to accept multiple development sources (for example, several machines debugging the application in the same network).

然后 remote_host 行被覆盖,因此您可以删除或评论它.

Then the remote_host line is being overriden, so you can remove or comment it.

这实际上是您当前正在运行的配置.那么,它有什么问题呢?运行此脚本检查一下:

This is effectively the configuration you are currently running. So, what's wrong with it? Check it out running this script:

<?
echo $_SERVER['REMOTE_ADDR'];

输出将是 ::1.好吧,向您的 Apache 服务器发出请求的主机是 localhost.Apache 将该名称解析为 IPv6 地址 ::1,这最终没有错.但是 Xdebug 无法连接到 IPv6 地址.见:

The output will be ::1. Well, the host which is making the request to your Apache server is localhost. And Apache is resolving that name as the IPv6 address ::1, which in the end is not wrong. But Xdebug is unable to connect to an IPv6 address. See:

I: Remote address found, connecting to ::1:9000.
E: Could not connect to client. :-(

因此,我们的目标是让 Apache 将 localhost 最好 解析为 IPv4 地址(在操作系统级别和 Apache 级别都不会禁用对 IPv6 的任何支持).这可以通过在 hosts 文件中添加下一行来实现:

So our goal will be to make Apache to resolve localhost preferably to an IPv4 address (without disabling any support for IPv6 at OS level nor at Apache level). This may be achieved by adding to your hosts file the next line:

127.0.0.1 localhost

这个简单的技巧就能解决问题!现在 localhost 总是最好被解析为 IPv4 地址,而 ::1 仍然可以完全理解.

This simple hack will do the trick! Now localhost will always preferably be resolved as an IPv4 address, while ::1 will still be perfectly understandable.

这篇关于PHP远程调试:XDebug无法连接JetBrains php Storm客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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