Debugging PHP Applications with Xdebug and Eclipse PDT

Posted by on Apr 13, 2008 in Eclipse, Programming, Technology, Web Development66 comments

Xdebug LogoOK, so I have x64 Eclipse successfully installed and running with all the plugins I use for Web Application Development. But what about debugging? Sure, var_dump(), echo, print and so on are all valuable to me when debugging a script, but it’s always good to have more information.

Xdebug is a fantastic PHP extension, which is written by one of the PHP Core Developers, Derick Rethans. The current version is 2.0.3, and I set about installing it on my system, and integrating it into Eclipse PDT today.

Xdebug can be installed in a few different ways – by downloading the binaries from the site, compiling the source, or via PECL:

sudo pecl install xdebug

Some days, I just prefer to download compile the source, as it gives me more of an understanding of what is being installed and where, and this is one of those days:

cd ~/
mkdir xdebug
cd xdebug
tar -zxvf xdebug-2.0.3.tgz
cd xdebug-2.0.3

The packages phpize and php-config are required to install Xdebug, and can be obtained by installing the relevant PHP development packages:

sudo apt-get install php4-dev


sudo apt-get install php5-dev

depending on the PHP version installed. After unzipping the Xdebug source, I ran


which output:

PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

I then checked this against the table at to see if my PHP version (5.2.3) was compatible with Xdebug – it matched up to the table’s 5.2.x PHP version row, so I went ahead and installed:

./configure --enable-xdebug --with-php-config=/usr/bin/php-config

which created a file in the modules subdirectory. This file needs to be copied (or moved) to the PHP Extension directory, which on my system is in /usr/lib/php5/20060613/. An easy way to find the PHP extension directory is to run:


ok, so I copied the to the extension directory:

sudo cp modules/ /usr/lib/php5/20060613/

So far so good. Now PHP needs to be told about the extension, and to load it. This can be done by adding


to the php.ini file. However, on my Ubuntu system, the PHP extensions are activated by adding an .ini file to the /etc/php5/apache2/conf.d directory, for each extension installed. The .ini file is the extension_name.ini, so I created a file called xdebug.ini:

cd /etc/php5/apache2/conf.d
gksu gedit xdebug.ini

which for now, contains a single line:


After restarting the Apache server

sudo /etc/init.d/apache2 restart

I created a file called test.php in my Web Root directory, containing a call to the phpinfo() function:


and pointed my browser to http://localhost/test.php. Just before the “PHP Credits” section, is a small box containing information on Zend – and now, with a successful Xdebug installation, additional information on Xdebug:

Xdebug information output by phpinfo()

The same information can be found by opening a Terminal and running

php -m

to output the loaded modules, and towards the end of the output, you should see

[Zend Modules]

alternatively, run

php -i | grep Xdebug

and if Xdebug has been installed successfully, you should see

with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans

Now, Xdebug needs to be enabled before any scripts can be debugged! So, in the php.ini file (or in my case, the newly created /etc/php5/apache2/conf.d/xdebug.ini file) I added the lines:


and restarted Apache again:

sudo /etc/init.d/apache2 restart


php -i | grep xdebug

in the Terminal, or using the test.php file containing phpinfo() shows that the new settings are being used, and Xdebug is active and running.

Configuring Eclipse PDT:

Setting up Eclipse PDT to use the Xdebug extension is pretty simple. In Eclipse PDT, I opened Window -> Preferences, then clicked on PHP, expanded the tree, and selected Debug. I Chose Xdebug from the pull down menu for the PHP Debugger, the “Default PHP Server” (should already be set to localhost), and then created a new PHP Executable option by clicking on the PHP Executables link next to the PHP Executable pull down menu.

XDebug and Eclipse PDT

In the PHP Executables dialog, I Clicked Add, filled in the name (PHP with XDebug), and entered the path to the PHP executable – on my system this is /usr/bin/php but if you don’t know, then in a terminal, run

which php

to find out where the php command is run from. I also entered the location of php.ini – again, on my system, this is /etc/php5/apache2/php.ini – and selected XDebug as the PHP debugger:

Xdebug - set up PHP Executable in Eclipse PDT

Clicked OK, then went back to the PHP -> Debug preferences screen, and selected the PHP Executable just created in the PHP Executable pull down. Finally, in the Debug -> Workbench Options option in the left, I selected “Never” for the “allow multiple debug sessions” option, since Xdebug does not support them.

Finally, I needed to set the Default Web Browser in Eclipse, to that when I debug a script, the output is sent to Firefox. Again in Preferences, I navigated to General -> Web Browser, and clicked “New”. It’s pretty straight forward stuff – entering a name and location – Firefox, and /usr/bin/firefox. Again, if you don’t know the location of the firefox binary, in a terminal run:

which firefox

With this done, and the preferences saved, I can now debug my scripts using Xdebug!

Using Xdebug in PDT


Tags: , , ,


» Comments RSS Feed
  1. […] Read more at 64 Bit Jungle […]

  2. Hi… thanks for your note.

    I have one question… Where I can get this eclipse theme? I want a dark interface to my Eclipse Installation.

    Sory, but my english is bad :(


  3. I wanna say “Thank YOU”!!!
    You realy help me!

  4. wow! thouroughly explained and it actually all worked! Thanks so much!!!

  5. These are some of the best tutorials I have found for a ubuntu newbe like myself. you list every step and asssume nothing. I am learning a lot. However I am stuck.
    When I click on Debug (F11) a firefox ‘opening index.php’ window pops up and asks if I want to open or save the file!

    PHP is definitely installed (clicking run works) xdebug is on the phpinfo.
    When I tired to find the location of php, it could not be found (although it was definitely already there.) I tried reinstalling it and pointing to it, but that has made no difference. anyone have any ideas?

  6. Thanks for the positive feedback all!

    @Pablo – the theme is just an Ubuntu dark theme, with some updates to the Eclipse display settings to create a dark background in the editor. You can change them in the Eclipse Preferences – specifically, the General -> Editors -> Text Editors section, and the PHP -> Editor -> Syntax Colouring sections.

    @Sky – could be a PHP/Apache misconfiguration – can you post the results to:

    more /var/log/apache2/error.log | tail

    and also the error_log file in the root directory of the site you’re debugging, just after running the debugger? For example, if your website is being developed in /home//public_html then run:

    more /home//public_html/error_log | tail

  7. Thanks for helping

    more /var/log/apache2/error.log | tail

    [Sun Nov 16 13:20:15 2008] [notice] child pid 10261 exit signal Segmentation fault (11)
    [Sun Nov 16 13:21:54 2008] [notice] child pid 10263 exit signal Segmentation fault (11)
    [Sun Nov 16 13:21:54 2008] [notice] child pid 10264 exit signal Segmentation fault (11)
    [Sun Nov 16 15:16:45 2008] [notice] child pid 10289 exit signal Segmentation fault (11)

    Server root is /home/sky/www/ project root is /home/sky/www/TestProject2/
    more /home/sky/www/TestProject2/error_log | tail
    /home/sky/www/TestProject2/error_log: No such file or directory
    more /home/sky/www/error_log | tail
    /home/sky/www/error_log: No such file or directory

    I’m currently running on the all in one (europa) pdt package, using your method of runnging 32bit eclipse on a 64 ubuntu.

    I’ve tried Ganymede as per your instructions (both 64 and 32 bit). I get an error when I try and open php files, which I havn’t been able to find any help with :
    An error has occurred. See error log for more details.

    I’ve also tried the zend all in one. php files run but the debugger does not catch anything.
    I’ve even tried getting xdebug to work on the zend instal but the software update does not work – can’t connect to server for some reason.

    I followed these instructions to instal AMP

  8. Update: I tried going through the whole process again.
    The only difference is that I am pointing at php5 in the preferences instead of php. (I tried this before with no effect.)
    It still does not work, but it no longer brings up the save dialog. It just loads the page and break points are not triggered. more /var/log/apache2/error.log | tail no longer lists the segmentation fault.

  9. It’s working.
    I added
    to the php.ini file rather than just the xdebug.ini file.
    could this be because the xdebug.ini file is in etc/php5/conf.d and not in /etc/php5/apache2 ?

  10. Hi Sky,

    glad to hear you got it all working! If you’re using Ununtu, the config file should be /etc/php5/apache2/conf.d/xdebug.ini since all of the apache/php config files are now split into modules in Ubuntu. Effectively, these are just extensions of the main php.ini file, and should be the same as adding the lines to php.ini. Since you have it working, I’d leave it be :)

    You may also be interested in Xdebug’s profiling functionality, by the way. You can switch it on by adding

    xdebug.profiler_enable = 1

    to the xdebug.ini (or, in your case the php.ini) file, then restart apache. Every time a page is processed, a file is dumped into the /tmp directory which you can open with a program such as kcachegrind and will give you a load of information on function processing time etc. Great for finding bottlenecks in code etc.

    Remember to switch profiling off when you don’t need it! Otherwise, you’ll have hundreds of files dumped.

  11. Thank you so much, you rock!

  12. Sky, I think I know what was you problem, as I’ve resolved the same just a minute ago:

    As told by Hodge, on Ubuntu you should have the configuration on xdebug.ini. That’s what I have and its working now, but it was not working before… so just after read your comment I went into my xdebug.ini with the intention of cut&paste its contents to the php.ini file to check if it solves also my problem but then I note that the double quotes on remote_host and remote_port values looks a bit weird, just a bit. I think I cut’n’pasted them from this webpage:

    And they was not pure ASCII characters.

    Effectively, I do a test with phpinfo and in xdebug section I found extrange characters on those fields:

    xdebug.remote_handler ”dbgp” ”dbgp”
    xdebug.remote_host ”localhost” ”localhost”

    So, I just change these weird quotes by normal double quotes, and everything began to work.

    I think that’s very possible that you’ve cut’n’paste the configuration from the same place, as there was a guy called “Sky” also posting comments there, and therefore your problem was the same. Later, you probably modify your php.ini copying data by hand of from this page instead of the other one, so the quotes was right ASCII characters.


  13. Good point Fran – always be careful to double check any configuration you copy & paste from sites, since as is often the case, characters such as double quotes are “beautified” by blog software, browsers etc. (unless contained within <code></code> tags)

  14. awesome article man.. it really helped alot.. thanks

  15. Hi I really hope somebody can help.
    I followed this tutorial very carefully and have xdebug installed correctly.
    My problem is that from PDT I cannot debug in a web page because it stalls with the message “waiting for XDebug Session”.
    I CAN use the script debug option.
    My php ini and using cli seem to report everything is as it should be.
    Furthermore I can actually write in XDebug function calls and get results. The anal side of me would like to get it working fully though, I have one of those personalities that can’t stand inperfection!
    Any ideas apreciated.

  16. sorry appreciated

  17. Hi, it? ok your article. Thanks

  18. This is a very clear tutorial.
    Worked out of the box for Ubuntu Jaunty, Eclipse PDT 2.
    Many thanks!

  19. @Garry Willits: Check the last page of HTH!

  20. I was also receiving “waiting for XDebug session” and figured out the problem. I had imported my project using SVN and the Default Web Browser had the absolute path to firefox on my mac. I changed this to /usr/bin/firefox and everything is working.

  21. nice tutorial.. i got a good explanation about debugger. it’s my first time using eclipse i always rely on var_dump()…. BTW, how can i achieve that exact kind of color theme? i’ve been looking all over the internet for a dark colored theme..

    thanks dude.

  22. buy cheap fedex lozol

  23. I solved my own version of this problem… After trying much of what I could find on the net, I thought to myself, “This is a Windows machine, I should reboot.” Nuff said.

  24. Newer version of PHP does not work with this.

  25. […] […]

  26. “Hi I really hope somebody can help.
    I followed this tutorial very carefully and have xdebug installed correctly.
    My problem is that from PDT I cannot debug in a web page because it stalls with the message “waiting for XDebug Session”.”

    I had the same problem (I am new to php). The cause was that my php sources were located in my Eclipse project dir instead of a dir in the Apache server root (htdocs) !

  27. […] Debugging PHP Applications with Xdebug and Eclipse PDT Squash bugs in PHP applications with Xdebug […]

  28. arimidex vs letrozole, arimidex online – arimidex weight loss, arimidex research

  29. There are various styles and designs to fit every golfer’s need. Golf eyewear with polarized lenses is especially helpful on bright, sunny days because they cut down the glare from sunlight that bounces off some surfaces. Different tints play a role, too, in how golfers view a course. Lenses that are amber in color filter blue light, and these are reputed to enhance viewing of far-off objects. Yellow and orange lenses are ideal for low-light conditions, while clear lenses are good for darker conditions. Some sunglasses for golfers also come with changeable lens systems – just snap in the lenses that are most suited for the current playing conditions. Whether one’s choice of sunglasses has dark or light lenses, it is important to remember that it should have excellent ultraviolet protection; some people mistakenly think that there is little or no risk of ultraviolet radiation on overcast days, but that simply isn’t so. UVA and UVB rays are just as dangerous on a cloudy day as they are on a sunny one. wholesale cheap oakley sunglasses

  30. buy generic avodart no prescription –; avodart new warnings is there a generic drug for avodart

  31. Instead, your doctor might not recommend exposing
    your body to heal itself and prevent how to get rid of acne breakouts.

  32. This paragraph is really a pleasant one it assists new net viewers, who are wishing
    in favor of blogging.

    – cliquez ici
    – cliquez ici
    – cliquez ici
    – cliquez ici
    – cliquez ici
    – cliquez ici

  33. Hey There. I found your blog using msn. This is a really well
    written article. I will be sure to bookmark it and come back to read more of your useful info.
    Thanks for the post. I’ll definitely return.

    – cliquez ici
    – cliquez ici
    – cliquez ici
    – cliquez ici
    – cliquez ici
    – cliquez ici

  34. Great post however , I was wondering if you could write a litte more on this subject?

    I’d be very thankful if you could elaborate a
    little bit further. Many thanks!

  35. Magnificent goods from you, man. I’ve understand your stuff previous to
    and you are just too excellent. I actually like what you have acquired here,
    really like what you’re saying and the way in which
    you say it. You make it enjoyable and you still take care of to keep it
    wise. I can’t wait to read much more from you.
    This is actually a wonderful site.

  36. whoah this weblog is great i like reading your articles.
    Stay up the good work! You already know, a lot of persons are hunting round
    for this info, you can aid them greatly.

  37. Howdy! Do you use Twitter? I’d like to follow
    you if that would be okay. I’m definitely enjoying your blog and look forward to new updates.

  38. This info is worth everyone’s attention. When can I find out more?

  39. I like looking through a post that can make people think.
    Also, thank you for allowing me to comment!

  40. Your style is very unique in comparison to other folks I have read stuff from.
    Many thanks for posting when you have the opportunity, Guess I’ll just bookmark this

  41. Word – Press iss incredibly easy to use,
    and can rank for your name wjth juist two orr three posts on it.

    Catching thee attention of the web users takes more than simple
    graphical designs. The Web – Kit browser also includes Adobe Flash Lite 3, supporting FLash appllications
    on the Web.

  42. No r?sulta f?c?l ver articulos correctamente escritos, asi q?e debo felicit?r al autor.S?guan as

  43. healthy weight loss diet

    Debugging PHP Applications with Xdebug and Eclipse PDT | 64 Bit Jungle

  44. ?    Neem has vitamin c which helps fight skin common problems like blackheads, dullness, pigmentation, blemishes, brittleness and aging.
    Allow it do the job overnight and within few days,
    you may discover the mole fading off. Probably one of the most important
    components of skin health is Vitamin A.

  45. Thanks for your personal marvelous posting! I truly enjoyed reading it,
    you happen to be a great author. I will ensure that I bookmark your blog and will come back in the future.

    I want to encourage one to continue your great posts, have a nice evening!

  46. Yesterday, while I was at work, my cousin stole my iPad and tested to see
    if it can survive a 40 foot drop, just so she can be a youtube sensation. My iPad is now broken and she has 83 views.
    I know this is completely off topic but I had to share it with

  47. I was recommended this web site by my cousin. I am not sure whether
    this post is written by him as no one else know such detailed about my difficulty.
    You’re amazing! Thanks!

  48. It is estimated that recurrent annd sustained use oof Phen375
    can result in a weejly loss of around 3 to
    5 lbs. Women in the study who skipped meals lost 8 fewer pounds, compared to thuose who ate regularly and just eating lunch outt once a
    week meant losing 5 fewer pounds. I had to drink a lot of water to get rid of the nasty taste.

  49. Wonderful goods from you, man. I’ve understand your
    stuff previous to and you are just extremely excellent. I actually like what you have
    acquired here, really like what you are saying and the way in which you say it.

    You make it enjoyable and you still take care of to keep it
    smart. I can not wait to read much more from you. This is really a great site.

  50. Nice weblog here! Also your website lots up very fast! What web host are
    you the use of? Can I am getting your affiliate link on your host?
    I want my web site loaded up as fast as yours lol

  51. I pay a qjick visit daily some blogs and websites to rerad articles or reviews,
    however this webpge offers feature based writing.

  52. Fashion is also used as a political weapon, for example in nineteenth century England it was
    against the law to wear clothes produced in France.
    Wear modern pastel tones for holidays in Spring,
    instead of Easter themed clothing. All fashions were hand-made, hand-sewn, seamstresses and tailors became
    a common trade and the difference between fashionable
    and just casual such as an off the shoulders dress became
    easy to distinguish and more and more people learned to express themselves, that is until sewing
    machines were invented and the clothing industry exploded.

  53. A weight loss program that is certainly high by utilizing fiber provides
    numerous advantages including cleansing and detoxification in the system, repair off blood glucose levels
    and high levels of at healthy levels, online marketing of
    weight-loss more effective weight reduction. You win or lose
    trophies based on if you win or lose attacks or defenses.
    You advance through these in order, and the overall storyline unfolds as you go.

  54. A visual masterpiece with a potent story about the sport of modern bodybuilding.

  55. Today, I went to the beachfront with my kids.

    I found a sea shell and gave it to my 4 year
    old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her
    ear and screamed. There was a hermit crab inside and it pinched her ear.

    She never wants to go back! LoL I know this is entirely off topic
    but I had to tell someone!

  56. I always spent my half an hiur tto read this web site’s articdles daily along with a cup of coffee.

  57. Yes! Finally something about web promotion.

  58. Neat blog! Is your theme custom made or did you download it from somewhere?
    A theme like yours with a few simple adjustements would really make my blog jump out.
    Please let me know where you got your theme. With thanks

  59. I do accept as true with all of the concepts you have presented
    on your post. They’re really convincing and can definitely work.
    Nonetheless, the posts are very brief for novices. May just you please lengthen them a bit from subsequent time?
    Thank you for the post.

  60. oto audi

    Debugging PHP Applications with Xdebug and Eclipse PDT | 64 Bit Jungle

  61. You could certainly see your enthusiasm within the work you write.
    The sector hopes for even more passionate writers like you who are not afraid
    to mention how they believe. At all times go after your heart.

  62. Wow, marvelous weblog format! How long have you ever
    been blogging for? you made running a blog glance easy.
    The full look of your website is great, as smartly as the content material!

  63. I was recommended this web site by means of my cousin. I am now not positive whether or not this post is written via
    him as nobody else recognise such designated about my problem.
    You are incredible! Thanks!


  65. Then, it’s going to be awfully hard to play one of those
    more traditional MMOs ever again, isn’t it. Where is it set — science fiction world,
    fantasy world, futuristic world. We want to catch and
    analyze as many bugs as possible during this
    stress test period, so that we can try to ensure a smooth launch on May 15.

  66. An accurate cast or image is critical to orthotic function. In 1982, he published his first book,
    The Agony of De-Feet: A Podiatrist Guide to
    Foot Care. Between the podiatrist, the gastroenterologist,
    the cardiologist, the nephrologist, the rheumatologist…someone is bound to find something wrong
    with you.

Leave a comment