Xdebug配置没问题,但是PhpStorm无法调试

Xdebug configuration is fine, but PhpStorm is unable to debug

我使用的是 PhpStorm 8.0.4 版,服务器是 Debian Wheeze PHP 5.4.4 和 Xdebug 2.1.1。

在 PhpStorm 上我有两个项目。项目 A 的调试工作正常,调试器在断点处停止,我能够观察变量并进入函数。

在与A项目调试配置相同的项目B上,调试器不会在断点处停止。

两个项目都存储在同一台服务器上,具有相同的 Apache、PHP 和 Xdebug 配置。他们只使用不同的虚拟主机。我遇到的唯一区别是,在项目 A 上,PhpStorm 使用 IDE 键在浏览器上设置 cookie XDEBUG_SESSION,但在项目 B 上,cookie 未设置。

接下来是项目 B 的示例调试会话:

Log opened at 2015-08-25 07:01:36
I: Checking remote connect back address.
I: Remote address found, connecting to <CLIENT IP>:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/projectB/script.php" language="PHP" protocol_version="1.0" appid="3137"><engine version="2.2.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2012 by Derick Rethans]]></copyright></init>

<- feature_set -i 1 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>

<- feature_set -i 2 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>

<- feature_set -i 3 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>

<- status -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="4" status="starting" reason="ok"></response>

<- step_into -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="5" status="break" reason="ok"><xdebug:message filename="file:///var/www/projectB/script.php" lineno="2"></xdebug:message></response>

<- run -i 6
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="6" status="stopping" reason="ok"></response>

<- stop -i 7
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stop" transaction_id="7" status="stopped" reason="ok"></response>

Log closed at 2015-08-25 07:01:36

更新

服务器在远程机器上,我 运行 PHP(和 Xdebug)使用 SSH 远程。 这是我正在尝试调试的示例脚本:

<?php
$a=1;
$b=2;
$c=$a+$b;
echo "c is: ".$c;

我在第 2 行 ($a=1;) 上设置了一个断点。 这是 Xdebug 日志:

Log opened at 2015-08-25 11:06:24
I: Checking remote connect back address.
I: Remote address found, connecting to <CLIENT IP>:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/vhost/test.php" language="PHP" protocol_version="1.0" appid="3602"><engine version="2.2.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2012 by Derick Rethans]]></copyright></init>

<- feature_set -i 1 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>

<- feature_set -i 2 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>

<- feature_set -i 3 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>

<- status -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="4" status="starting" reason="ok"></response>

<- step_into -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="5" status="break" reason="ok"><xdebug:message filename="file:///var/www/vhost/test.php" lineno="2"></xdebug:message></response>

<- run -i 6
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="6" status="stopping" reason="ok"></response>

<- stop -i 7
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stop" transaction_id="7" status="stopped" reason="ok"></response>

Log closed at 2015-08-25 11:06:24

别告诉我为什么,但我通过按调试菜单中的 "Start listening for PHP Debug Connections" 按钮解决了我的问题。