关于Sublime文本的xDebug似乎无法正常工作

时间:2016-03-31 08:27:25

标签: php sublimetext3 sublimetext xdebug

我已经在Vagrant guest Ubuntu 14.04系统上安装了Xdebug,并将其设置为在我的OSX主机系统上使用SublimeText3。我按照here的说明进行操作。

一切似乎都有点工作但是当我运行Xdebug时,断点不会变黄并且不清楚代码Xdebug中的哪一点,我确实看到了上下文面板。

enter image description here

当我检查xDebug日志时,我看到它连接到客户端,然后说它无法连接到客户端。

Log opened at 2016-03-31 08:08:59
I: Connecting to configured address/port: 10.0.2.2:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///vagrant/httpdocs/project-2/index.php" language="PHP" xdebug:language_version="5.5.9-1ubuntu4.14" protocol_version="1.0" appid="2256" idekey="XDEBUG_ECLIPSE"><engine version="2.4.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>

<- feature_set -i 1 -v 1 -n show_hidden
-> <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 -v 32 -n max_children
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

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

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

<- breakpoint_set -i 5 -n 40 -f file%3A///var/www/project-2/index.php -t line
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5" id="22560001"></response>

<- breakpoint_set -i 6 -n 20 -f file%3A///Users/holy/ubuntu_1404/httpdocs/project-1/app/design/frontend/hoi/default/template/page/html/header.phtml -t line
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="22560002"></response>

<- breakpoint_set -i 7 -x "Fatal error" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="22560003"></response>

<- breakpoint_set -i 8 -x "Catchable fatal error" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="22560004"></response>

<- breakpoint_set -i 9 -x "Warning" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="22560005"></response>

<- breakpoint_set -i 10 -x "Parse error" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="10" id="22560006"></response>

<- breakpoint_set -i 11 -x "Notice" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="11" id="22560007"></response>

<- breakpoint_set -i 12 -x "Strict standards" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="12" id="22560008"></response>

<- breakpoint_set -i 13 -x "Deprecated" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="13" id="22560009"></response>

<- breakpoint_set -i 14 -x "Xdebug" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="14" id="22560010"></response>

<- breakpoint_set -i 15 -x "Unknown error" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="15" id="22560011"></response>

<- run -i 16
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="16" status="break" reason="ok"><xdebug:message filename="file:///vagrant/httpdocs/project-2/index.php" lineno="40"></xdebug:message></response>

<- context_get -i 17 -c 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="17" context="1"><property name="$_COOKIE" fullname="$_COOKIE" type="array" children="1" numchildren="3" page="0" pagesize="32"><property name="__zlcmid" fullname="$_COOKIE[&#39;__zlcmid&#39;]" type="string" size="14" encoding="base64"><![CDATA[WnBmUVZIclEzSWtiQmU=]]></property><property name="PHPSESSID" fullname="$_COOKIE[&#39;PHPSESSID&#39;]" type="string" size="26" encoding="base64"><![CDATA[YWplcjAyaGh1bjVya2djZXBiaDc2cjFhbTU=]]></property><property name="XDEBUG_SESSION" fullname="$_COOKIE[&#39;XDEBUG_SESSION&#39;]" type="string" size="14" encoding="base64"><![CDATA[WERFQlVHX0VDTElQU0U=]]></property></property><property name="$_ENV" fullname="$_ENV" type="array" children="0" numchildren="0" page="0" pagesize="32"></property><property name="$_FILES" fullname="$_FILES" type="array" children="0" numchildren="0" page="0" pagesize="32"></property><property name="$_GET" fullname="$_GET" type="array" children="0" numchildren="0" page="0" pagesize="32"></property><property name="$_POST" fullname="$_POST" type="array" children="0" numchildren="0" page="0" pagesize="32"></property><property name="$_REQUEST" fullname="$_REQUEST" type="array" children="0" numchildren="0" page="0" pagesize="32"></property><property name="$_SERVER" fullname="$_SERVER" type="array" children="1" numchildren="35" page="0" pagesize="32"><property name="SCRIPT_URL" fullname="$_SERVER[&#39;SCRIPT_URL&#39;]" type="string" size="1" encoding="base64"><![CDATA[Lw==]]></property><property name="SCRIPT_URI" fullname="$_SERVER[&#39;SCRIPT_URI&#39;]" type="string" size="29" encoding="base64"><![CDATA[aHR0cDovL2Rldi5kaWV0LWV4cGVydC5sb2NhbC8=]]></property><property name="HTTP_AUTHORIZATION" fullname="$_SERVER[&#39;HTTP_AUTHORIZATION&#39;]" type="string" size="0" encoding="base64"><![CDATA[]]></property><property name="HTTP_HOST" fullname="$_SERVER[&#39;HTTP_HOST&#39;]" type="string" size="21" encoding="base64"><![CDATA[ZGV2LmRpZXQtZXhwZXJ0LmxvY2Fs]]></property><property name="HTTP_CONNECTION" fullname="$_SERVER[&#39;HTTP_CONNECTION&#39;]" type="string" size="10" encoding="base64"><![CDATA[a2VlcC1hbGl2ZQ==]]></property><property name="HTTP_CACHE_CONTROL" fullname="$_SERVER[&#39;HTTP_CACHE_CONTROL&#39;]" type="string" size="9" encoding="base64"><![CDATA[bWF4LWFnZT0w]]></property><property name="HTTP_ACCEPT" fullname="$_SERVER[&#39;HTTP_ACCEPT&#39;]" type="string" size="74" encoding="base64"><![CDATA[dGV4dC9odG1sLGFwcGxpY2F0aW9uL3hodG1sK3htbCxhcHBsaWNhdGlvbi94bWw7cT0wLjksaW1hZ2Uvd2VicCwqLyo7cT0wLjg=]]></property><property name="HTTP_UPGRADE_INSECURE_REQUESTS" fullname="$_SERVER[&#39;HTTP_UPGRADE_INSECURE_REQUESTS&#39;]" type="string" size="1" encoding="base64"><![CDATA[MQ==]]></property><property name="HTTP_USER_AGENT" fullname="$_SERVER[&#39;HTTP_USER_AGENT&#39;]" type="string" size="120" encoding="base64"><![CDATA[TW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTFfMikgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzQ5LjAuMjYyMy44NyBTYWZhcmkvNTM3LjM2]]></property><property name="HTTP_ACCEPT_ENCODING" fullname="$_SERVER[&#39;HTTP_ACCEPT_ENCODING&#39;]" type="string" size="19" encoding="base64"><![CDATA[Z3ppcCwgZGVmbGF0ZSwgc2RjaA==]]></property><property name="HTTP_ACCEPT_LANGUAGE" fullname="$_SERVER[&#39;HTTP_ACCEPT_LANGUAGE&#39;]" type="string" size="32" encoding="base64"><![CDATA[ZW4tVVMsZW47cT0wLjgsc3Y7cT0wLjYsZXM7cT0wLjQ=]]></property><property name="HTTP_COOKIE" fullname="$_SERVER[&#39;HTTP_COOKIE&#39;]" type="string" size="92" encoding="base64"><![CDATA[X196bGNtaWQ9WnBmUVZIclEzSWtiQmU7IFBIUFNFU1NJRD1hamVyMDJoaHVuNXJrZ2NlcGJoNzZyMWFtNTsgWERFQlVHX1NFU1NJT049WERFQlVHX0VDTElQU0U=]]></property><property name="PATH" fullname="$_SERVER[&#39;PATH&#39;]" type="string" size="60" encoding="base64"><![CDATA[L3Vzci9sb2NhbC9zYmluOi91c3IvbG9jYWwvYmluOi91c3Ivc2JpbjovdXNyL2Jpbjovc2JpbjovYmlu]]></property><property name="SERVER_SIGNATURE" fullname="$_SERVER[&#39;SERVER_SIGNATURE&#39;]" type="string" size="81" encoding="base64"><![CDATA[PGFkZHJlc3M+QXBhY2hlLzIuNC43IChVYnVudHUpIFNlcnZlciBhdCBkZXYuZGlldC1leHBlcnQubG9jYWwgUG9ydCA4MDwvYWRkcmVzcz4K]]></property><property name="SERVER_SOFTWARE" fullname="$_SERVER[&#39;SERVER_SOFTWARE&#39;]" type="string" size="21" encoding="base64"><![CDATA[QXBhY2hlLzIuNC43IChVYnVudHUp]]></property><property name="SERVER_NAME" fullname="$_SERVER[&#39;SERVER_NAME&#39;]" type="string" size="21" encoding="base64"><![CDATA[ZGV2LmRpZXQtZXhwZXJ0LmxvY2Fs]]></property><property name="SERVER_ADDR" fullname="$_SERVER[&#39;SERVER_ADDR&#39;]" type="string" size="13" encoding="base64"><![CDATA[MTkyLjE2OC45OS45OQ==]]></property><property name="SERVER_PORT" fullname="$_SERVER[&#39;SERVER_PORT&#39;]" type="string" size="2" encoding="base64"><![CDATA[ODA=]]></property><property name="REMOTE_ADDR" fullname="$_SERVER[&#39;REMOTE_ADDR&#39;]" type="string" size="12" encoding="base64"><![CDATA[MTkyLjE2OC45OS4x]]></property><property name="DOCUMENT_ROOT" fullname="$_SERVER[&#39;DOCUMENT_ROOT&#39;]" type="string" size="20" encoding="base64"><![CDATA[L3Zhci93d3cvZGlldGF2ZW51ZS8=]]></property><property name="REQUEST_SCHEME" fullname="$_SERVER[&#39;REQUEST_SCHEME&#39;]" type="string" size="4" encoding="base64"><![CDATA[aHR0cA==]]></property><property name="CONTEXT_PREFIX" fullname="$_SERVER[&#39;CONTEXT_PREFIX&#39;]" type="string" size="0" encoding="base64"><![CDATA[]]></property><property name="CONTEXT_DOCUMENT_ROOT" fullname="$_SERVER[&#39;CONTEXT_DOCUMENT_ROOT&#39;]" type="string" size="20" encoding="base64"><![CDATA[L3Zhci93d3cvZGlldGF2ZW51ZS8=]]></property><property name="SERVER_ADMIN" fullname="$_SERVER[&#39;SERVER_ADMIN&#39;]" type="string" size="23" encoding="base64"><![CDATA[Y29udGFjdEBkaWV0LWV4cGVydC5jb20=]]></property><property name="SCRIPT_FILENAME" fullname="$_SERVER[&#39;SCRIPT_FILENAME&#39;]" type="string" size="29" encoding="base64"><![CDATA[L3Zhci93d3cvZGlldGF2ZW51ZS9pbmRleC5waHA=]]></property><property name="REMOTE_PORT" fullname="$_SERVER[&#39;REMOTE_PORT&#39;]" type="string" size="5" encoding="base64"><![CDATA[NDk0MzY=]]></property><property name="GATEWAY_INTERFACE" fullname="$_SERVER[&#39;GATEWAY_INTERFACE&#39;]" type="string" size="7" encoding="base64"><![CDATA[Q0dJLzEuMQ==]]></property><property name="SERVER_PROTOCOL" fullname="$_SERVER[&#39;SERVER_PROTOCOL&#39;]" type="string" size="8" encoding="base64"><![CDATA[SFRUUC8xLjE=]]></property><property name="REQUEST_METHOD" fullname="$_SERVER[&#39;REQUEST_METHOD&#39;]" type="string" size="3" encoding="base64"><![CDATA[R0VU]]></property><property name="QUERY_STRING" fullname="$_SERVER[&#39;QUERY_STRING&#39;]" type="string" size="0" encoding="base64"><![CDATA[]]></property><property name="REQUEST_URI" fullname="$_SERVER[&#39;REQUEST_URI&#39;]" type="string" size="1" encoding="base64"><![CDATA[Lw==]]></property><property name="SCRIPT_NAME" fullname="$_SERVER[&#39;SCRIPT_NAME&#39;]" type="string" size="10" encoding="base64"><![CDATA[L2luZGV4LnBocA==]]></property></property></response>

<- context_get -i 18
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="18" context="0"><property name="$compilerConfig" fullname="$compilerConfig" type="uninitialized"></property><property name="$mageFilename" fullname="$mageFilename" type="uninitialized"></property><property name="$mageRunCode" fullname="$mageRunCode" type="uninitialized"></property><property name="$mageRunType" fullname="$mageRunType" type="uninitialized"></property><property name="$maintenanceFile" fullname="$maintenanceFile" type="uninitialized"></property></response>

<- stack_get -i 19
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="19"><stack where="{main}" level="0" type="file" filename="file:///vagrant/httpdocs/project-2/index.php" lineno="40"></stack></response>

Log opened at 2016-03-31 08:09:06
I: Connecting to configured address/port: 10.0.2.2:9000.
E: Could not connect to client. :-(
Log closed at 2016-03-31 08:09:06

Log opened at 2016-03-31 08:09:06
I: Connecting to configured address/port: 10.0.2.2:9000.
E: Could not connect to client. :-(
Log closed at 2016-03-31 08:09:06

Log opened at 2016-03-31 08:09:06
I: Connecting to configured address/port: 10.0.2.2:9000.
E: Could not connect to client. :-(
Log closed at 2016-03-31 08:09:06

我正在使用10.0.2.2作为php.ini文件中的远程主机。

xdebug.remote_host=10.0.2.2

我刚从教程中接受了这个设置,它似乎工作,首先我尝试了10.0.2.15,因为它是我在流浪汉ssh时看到的IP地址

IP address for eth0: 10.0.2.15

还有ifconfig

vagrant@dev:/var/log/xdebug$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:c9:24:d6  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fec9:24d6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1297 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1004 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:118158 (118.1 KB)  TX bytes:157804 (157.8 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:f4:70:ac  
          inet addr:192.168.99.99  Bcast:192.168.99.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fef4:70ac/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1024 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1263 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:142856 (142.8 KB)  TX bytes:1993376 (1.9 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:104 errors:0 dropped:0 overruns:0 frame:0
          TX packets:104 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8804 (8.8 KB)  TX bytes:8804 (8.8 KB)

但是当我使用10.0.2.15作为远程主机时,xDebug根本没有连接。

/etc/php5/apache2/php.ini

zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.default_enable = 1
xdebug.idekey = "vagrant"
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_port = 9000
xdebug.remote_handler=dbgp
xdebug.remote_log="/var/log/xdebug/xdebug.log"
xdebug.remote_host= 10.0.2.2 ; IDE-Environments IP, from vagrant box

project.sublime项目

{
    "folders":
    [
        {
            "path": "/Users/holy/ubuntu_1404/httpdocs/project"
        }
    ],
    "settings": {
        "xdebug": {
        "path_mapping": {
                 "/var/www/project" : "/Users/holy/ubuntu_1404/httpdocs/project",
            },
        "url": "http://dev.project.local/",
        "super_globals": true,
        "close_on_stop": true
        }
    }
}

更新

在尝试了来自@MarcinOrlowski的建议答案之后,似乎是在日志中工作,但在Sublime中,断点仍然没有变黄,我无法看到Xdebug在sublime中的代码中的哪一点。

Log opened at 2016-03-31 08:48:15
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 192.168.99.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///vagrant/httpdocs/project/index.php" language="PHP" xdebug:language_version="5.5.9-1ubuntu4.14" protocol_version="1.0" appid="2626" idekey="XDEBUG_ECLIPSE"><engine version="2.4.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>

<- feature_set -i 1 -v 1 -n show_hidden
-> <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>

第二次更新

有关远程主机的更多详细信息......

vagrant@dev:~$ route | grep default | awk '{print $2}'
10.0.2.2
vagrant@dev:~$ telnet 10.0.2.2 9000
Trying 10.0.2.2...
telnet: Unable to connect to remote host: Connection refused
vagrant@dev:~$ tcpdump port 9000
tcpdump: no suitable device found

1 个答案:

答案 0 :(得分:1)

我删除/** * @var bigint * * @ORM\Column(name="recid", type="bigint") * @ORM\Id */ private $recid; 条目,但添加remote_host代替docs):

  

如果启用,则忽略xdebug.remote_host设置,Xdebug将设置   尝试连接到发出HTTP请求的客户端。

所以这应该可以解决问题(你可能需要先在vagrant上重启httpd)

remote_connect_back

BTW:xdebug.remote_handler="dbgp" xdebug.remote_port=9000 xdebug.remote_autostart = on xdebug.remote_start = on xdebug.remote_enable = on xdebug.remote_connect_back = on xdebug.idekey = "vagrant" 路径可以是相对的,如果您已正确设置extension_dir

zend_extension