PHP 远程调试:XDebug 无法连接到 JetBrains php Storm 客户端


PHP remote debugging: XDebug can't connect to JetBrains php Storm client

我想让远程调试使用以下软件配置:

赢 7 专业版 64 位WAMP Server 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

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

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

2.( 我安装了 php 扩展 XDebug 并将以下行添加到我的 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 和回调地址。

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

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

然后在这里检查了我的设置

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

(我也尝试了 127.0.0.1/fox 作为服务器地址,而是本地主机(

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

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

Run  -> Start listen to PHP Debug Connections

电话接收器呈绿色,这到底意味着什么,但这对我来说是一个积极的信号。

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

在 Xdebuggers 日志 (C:/wamp/tmp/xdebug.log( 中,我发现了大量如下消息:

 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防火墙可以阻止通信,所以我完全关闭了它,但这没有帮助。

我还尝试通过telnet连接到localhost:9000,我得到了phpstorm的回复。

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

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

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

也许有点晚了,但是...

在这里,您的设置存在矛盾:

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

这两个设置重叠。你的情况如何?

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

然后您几乎完成了:您已经定义了远程主机是 localhost 。注释掉remote_connect_back行(带;(

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

然后,remote_host行将被覆盖,因此您可以删除或注释它。

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

<?
echo $_SERVER['REMOTE_ADDR'];

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

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

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

127.0.0.1 localhost

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

您可以

尝试禁用IPV6 http://support.microsoft.com/kb/929852,我认为这是问题所在,当您尝试连接时。

找到远程地址,连接到 ::1:9000。

系统正在尝试与IPV6连接,我认为XDebug仅适用于IPV4。

代码中的断点到底在哪里?我知道XDebug可能很有趣。

对于 PHP 5.4,您的 Xdebug 设置应该是

[XDebug]
zend_extension="<path to php_xdebug.dll>"
xdebug.remote_enable=1
xdebug.remote_port="<the port for XDebug to listen to>" (the default port is 9000)
xdebug.profiler_enable=1
xdebug.profiler_output_dir="<AMP home'tmp>"

http://www.jetbrains.com/phpstorm/webhelp/configuring-xdebug.html