Eclipse – Using XDebug with Eclipse PDT & XAMPP

eclipsexamppxdebug

I cannot debug a PHP script as a script. It always terminates immediately after starting. I set up an Xdebug log in my php.ini, but it's completely unhelpful. Xdebug does show up on my phpinfo(), so I know it's loaded in Apache.

I can also debug code as a webpage (which provides no info on variables and will not stop on breakpoints though), so I know Eclipse has the proper server settings. Both debug options use the same PHP exe (the one installed with XAMPP, php 5.3.1 compiled with vc6 compiler). I made sure that the compilation of Xdebug matched these settings.

On a perhaps related note: I noticed that I could only load Xdebug with the zend_extension command, instead of zend_extension_ts even though my version of PHP is indeed thread safe? I have to admit I'm a little confused by that.

I also made very sure that wherever I could select "XDebug" in Eclipse, I did. I've followed two tutorials to no avail here. Anyone have any ideas? I've tried the version of Xdebug bundled with my XAMPP (2.0.6-dev) and I also downloaded a new .dll, version 2.1.

Thanks!

Best Answer

Excellent instructions for Setup XDebug on XAMPP and Eclipse @user629300 Instructions are good for eclipse versions prior to 3.5 see the links to get instructions for version based instructions. Also Getting XDebug to work with apache xampp to debug php, has pictures with good explanations. They are a little stale though.


A summary of the details from the first link, assuming PHP > 5.3 (which hopefully everyone is running now!):

  • Make sure that your php.ini file contains the following:

    [XDebug]
    zend_extension={xampp-folder}\php\ext\php_xdebug.dll
    xdebug.remote_enable=1
    xdebug.remote_host="localhost"
    xdebug.remote_port=9000
    xdebug.remote_handler="dbgp"
    
  • Remove any config entries under the [Zend] heading, particularly those starting with zend_extension
  • Configure Eclipse:
    • in Window -> Preferences -> PHP -> Servers, configure the PHP server to use XDebug, add the base URL and local web root
    • in -> Installed debuggers, configure XDebug to accept remote sessions
    • (optional?) configure the PHP executable to point to php.exe in your XAMPP installation

You should now be able to hit breakpoints in Eclipse by adding XDEBUG_SESSION_START to the query string of your URL, e.g. http://localhost/?XDEBUG_SESSION_START.

Related Topic