1
votes

I'm trying to get Eclipse to talk to xdebug. From the xdebug log, it seems that xdebug is working correctly (i.e.: it's sending it's <init> and <response> messages), but Eclipse is not sending anything to xdebug (i.e.: no feature_set, feature_get, etc. commands like Netbeans).


Here's my setup:

  • Mac OS/X 10.7.5
  • Eclipse 4.2.1 "Juno"
    • PHP Development Tools (PDT) SDK Feature 3.1.1.201209101312
  • (Netbeans 7.1.2)
  • MAMP 2.1.1 running:
    • apache 2.2.22
    • PHP 5.4.4
      • the PHP executable being run is /Applications/MAMP/bin/php/php5.4.4/bin/php
      • the PHP config file being used is /Applications/MAMP/bin/php/php5.4.4/conf/php.ini
      • xdebug 2.2.0

The relevant lines from my php.ini are:

[xdebug]
zend_extension = "/Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
xdebug.default_enable = on
xdebug.remote_enable = on
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.remote_autostart = on
xdebug.remote_handler = "dbgp"
xdebug.remote_autostart = on
xdebug.remote_mode = "req"
xdebug.remote_connect_back = on
xdebug.remote_log = /tmp/xdebuglog.log

I can get Netbeans to connect to xdebug on port 9000 with session ID netbeans-xdebug with no problem. Note that when I start debugging, it opens a new window in my web browser with ?XDEBUG_SESSION_START=netbeans-xdebug appended to the URL of the PHP file I'm running.

Here is a snippet from the xdebug log when Netbeans tries to connect:

Log opened at 2013-01-18 18:42:52
I: Checking remote connect back address.
I: Remote address found, connecting to ::1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Applications/MAMP/htdocs/projectname/index.php" language="PHP" protocol_version="1.0" appid="647" idekey="netbeans-xdebug"><engine version="2.2.0"><![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 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

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

<- feature_set -i 2 -n max_children -v 30
-> <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_get -i 3 -n max_data
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_get" transaction_id="3" feature_name="max_data" supported="1"><![CDATA[1024]]></response>

<- stdout -i 4 -c 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stdout" transaction_id="4" success="1"></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:///Applications/MAMP/htdocs/projectname/index.php" lineno="17"></xdebug:message></response>

<- stack_get -i 6
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="6"><stack where="{main}" level="0" type="file" filename="file:///Applications/MAMP/htdocs/projectname/index.php" lineno="17"></stack></response>

…

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

Log closed at 2013-01-18 18:47:21

In Eclipse…

I created a new PHP Project in the workspace, using the default PHP settings, and created separate folders for source files and public resources. I changed nothing in the PHP Include Path step, but in the PHP Build Path, I clicked Link Source and linked /Applications/MAMP/htdocs/projectname with a projectname folder in my project.

I then set Eclipse preferences as follows:

  • In General -> Web Browser, I've set it to use an external web browser (Firefox).
  • In PHP -> Debug -> Installed Debuggers, I've checked that XDebug is in the list, is using port 9000, JIT remote sessions are off, and I used these instructions to ensure it uses the idekey mparker17.
  • In PHP -> Debug, I:
    • Set the PHP Debugger to "XDebug"
    • Set the PHP Server to the correct base URL (http://projectname.local) local web root (/Applications/MAMP/htdocs/projectname) and path mapping between the server and my workspace.
    • Set the PHP Executable to the correct executable path (/Applications/MAMP/bin/php/php5.4.4/bin/php), PHP ini file (/Applications/MAMP/bin/php/php5.4.4/conf/php.ini), the SAPI type to "CLI" and the PHP debugger to "XDebug".
    • Checked the Enable CLI Debug checkbox.
    • Checked the Break at first line checkbox.

In my debug configurations, I added a PHP Web Application and set it's preferences as follows:

  • In the Server tab I set the PHP server created above, set the file correctly, and set the URL correctly.

Here is a snippet from the xdebug log when Eclipse tries to connect:

Log opened at 2013-01-18 17:33:48
I: Checking remote connect back address.
I: Remote address found, connecting to ::1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Applications/MAMP/htdocs/projectname/index.php" language="PHP" protocol_version="1.0" appid="703" idekey="mparker17"><engine version="2.2.0"><![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>

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

Log closed at 2013-01-18 17:33:49

This seems to indicate to me that Eclipse isn't talking to xdebug, but I'm stumped as to why that would be happening.

1

1 Answers

0
votes

JIT remote sessions are off

Turn it on.