My previous post touched upon the basics of getting Eclipse PDT (PHP Development Tools) up and running for PHP development. In this post, we’ll be looking at getting PHP debugging capabilities into our PHP dev environment. Again, I’ll be focusing on Ubuntu Linux – 8.04 LTS to be specific: however, with minor changes, this can be used on any platform.
Of course, there are simpler methods of debugging PHP scripts: a var_dump is quite handy in terms of simple debugging – however, having the right tools at hand for development means that we can spend more time in actual development than writing debug statements every once in a while – anyways, that’s my take.
XDebug is a remote debugger. Here we’ll take a look at getting XDebug working with Eclipse PDT providing a full debugging client. The first step would of course be to get Eclipse PDT up and running (refer previous post if needed). Once done, the next step would be to get Xdebug for our PHP environment set up – in my case, PHP5. On Ubuntu, this can be achieved by:
apt-get install php5-xdebug
This should install Xdebug for PHP5. Next, we’d configure Xdebug by editing the PHP configuration file. Most systems require the configuration items be added to the main php.ini, or the appropriate conf file. In Ubuntu 8.04 LTS, a separate configuration file,xdebug.ini, is created for Xdebug. Open this file using your favorite text editor (vim in my case):
sudo vim /etc/php5/conf.d/xdebug.ini
Add the following lines after the zend_extension= or zend_extension_ts= conf value.
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
And restart your web-server. In my case, Apache:
/etc/init.d/apache2 restart
To try out the debugger, open a PHP project in Eclipse (if you are importing an existing project via CVS, remember to add it as a PHP project using the New Project Wizard). In Window->Preferences->General->Web Browser, select external web browser, and set it to point to your default web browser. Next go into the debug section, by Window->Preferences->PHP->Debug, and set the PHP Debugger option to XDebug (by default this is set to the Zend Debugger). Note the chekbox “Break at first line” in this page as well – you can change this later on, as required. After you’ve applied your changes, go into the Debug menu, by Run->Open Debug Dialog… Here, make sure the Server Debugger is set to XDebug, and that the PHP server points to http://localhost or an appropriate server location. The file section should point to the file to be debugged, relative to your workspace (Note: if your project is missing from the list, check whether you’re project is configured as a PHP project – I’ve noticed that non-PHP projects fail to appear on this list). Thus if your file is index.php, the relative path maybe something/www/index.php etc.
Next, check the URL section to see whether it points to the correct location – if not, make sure you uncheck the “Auto-Generate” check box, and enter in the correct location. Apply the changes and close the dialog box.
A view of the Debug dialog is here:

You should now be ready to debug your application. Click on Run->Debug or F11 to enable debugging – Eclipse should switch to the Debug View, and the page should start loading in your external browser. If “Break at First Line” checkbox was checked previously, then the program would have “stopped” at the first line – you can step into or step over subsequent lines using the controls on your top left corner. Alternatively, you can place breakpoints at various locations and stop code execution there as well. The variables tab should give you the variables and their values at various times. I good guide from which I borrowed from is here. Get creative – start debugging.
A view of the debugger in operation is here:




Dear,
I’m using Firefox 3.0, Version: 3.3.2 on Ubuntu. After all config, i press F11 to debug. Firefox is opened, it create a new tab with name is Untitled an show download dialog require I download *.php file. And Eclipse doesn’t not with to debug view.
Help me!
Thanks,
Comment by trunghpb — November 14, 2008 @ 3:32 pm |
#trunghpb I’ve got exactly the same problem. Can’t find a solution anywhere. did you have any luck?
Comment by Sky — November 15, 2008 @ 11:53 pm |
I fixed this by reinstaling and pointing window>preferences>Php>php executables to my php5 file rather than php.In my case /usr/bin/php
Comment by Sky — November 16, 2008 @ 4:24 pm |
I’m having the same problema as trunghbp and Sky, but I cannot change that setting, when I try to modify it Eclipse says: “This is a predefined PHP executable configuration which cannot be modified”
Comment by Fran — March 20, 2009 @ 2:46 pm |
Tried this. After trying for a while to get zend going, I came across this post and gave xdebug a shot. Surprisingly easy, I’m glad to finally be able to debug php. You should post this on the Ubuntu help wiki. Thanks dude.
Comment by ricardo — July 2, 2009 @ 2:38 am |
Thanks for the article.
One thing that surprises me is the requirement to configure the Eclipse feature to get to the “file to be debugged”. I have projects with large numbers of files. Am I supposed to create a new configuration for each file I want to debug? Seems incredibly complex to do. Wouldn’t Eclipse be capable of just taking the name of the script I’m clicking on *dynamically* and then apply the debug mechanism to it?
You might not have any involvement in this plugin, and I’m certainly not accusing anyone (just to make sure). I’m just wondering if I’m the only one having this problem and if there is a solution…
Thanks,
Yannick
Comment by ywarnier — July 22, 2009 @ 8:07 pm |
[...] Debugging PHP in Eclipse using XDebug – Eclipse Debugging [...]
Pingback by Xdebug Remote Debugging — August 15, 2009 @ 6:08 am |
Thanks for your help! i’ve been trying to get it working for a long time, but my efforts were fruitless. This guide made it really easy!
Comment by Bram — August 27, 2009 @ 6:31 pm |
I followed your instructions, but my debug go straight on to the end and does not stop at breakpoint…I am on Kubuntu 9.04 but the config file is the same as 8.04…any help please? Two days I am working on it…
Comment by Alex — September 15, 2009 @ 5:04 pm |
sorry, lost subscription…
Comment by Alex — September 15, 2009 @ 5:07 pm |
That worked for me!
Thank you so much
Comment by Faber — October 4, 2009 @ 7:57 am |
it is really helpfull , thanks a lot
Comment by harsha halgaswatta — January 16, 2010 @ 8:54 pm |
Thanks! saved me a lot of time
Comment by Assaf Karmon — March 7, 2010 @ 6:50 pm |
THANK YOU! You have the most coherent and helpful guide to setting up PHP debugging in Eclipse on Ubuntu, and I really appreciate it.
— Jennifer Hodgdon
Comment by Jennifer Hodgdon — April 16, 2010 @ 8:01 pm |
Agree, this was really helpful! I had a problem though where Eclipse would not open a browser window whenever I tried to debug. I could debug fine in NetBeans, so I knew the problem wasn’t with XDebug, but rather with Eclipse. Checked the Eclipse log (workspace/.metadata/.log) and saw:
!MESSAGE The debug port 10000 is in use. Please select a different port for the debugger.
Odd, since 10000 is the port assigned to Zend Debugger, and I had set things up to use XDebug. At any rate, after switching the Zend Debugger to an unused port (10000 is the default port for webmin), I was able to successfully launch a browser and use Xdebug as usual.
Comment by Kristin Stromberg — May 19, 2010 @ 12:51 am |
thank you thank you thank you!!!!!!!!!!!!!!!!!!!!!!!!
I was struggling since weeks!!!!
Comment by mike — December 29, 2010 @ 10:43 am |
I’m about to crying…I believed I was lost but now I see the light…thank you!
Comment by ironman_xx — June 9, 2012 @ 8:19 pm |
when you lost:
1. save current php.ini file as php.ini.old
2. open php.ini-dist and save as php.ini
3. download and save in correct position the exact Xdebug version.
4. add required lines at the end with full path.
5. restart your web-server
this work for me
thanks all
Comment by Shimon — June 17, 2010 @ 7:44 am |
It’s nice post.
Thanks you so much.
Comment by Pankit — July 2, 2010 @ 5:40 am |
I had the same problem as Alex reported before: The debugger didn’t stop or “catch” the breakpoints, only the first line (since I had checked the option to stop on first line in the Run configuration).
By enabling logging (added the line
xdebug.remote_log=”/tmp/xdebug.log”
in /etc/php5/conf.d/xdebug.ini), I found out what was happening.
Solution was: I had changed location of my www folder (to /home/[username]/www instead of /var/www), and forgot to update the path mapping in
Run > Debug configuration > “Server” tab > “Configure button” beside PHP Server config line > “Path mapping” tab
After changing this it works!
Btw, I also have to include the following line in the xdebug.ini file:
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
(exact path can be different depending on php version)
Comment by Samuel Lampa — July 13, 2010 @ 4:31 pm |
Btw, I should mention about this bug with Eclipse Helios, which is reported to cause the same problem: https://bugs.eclipse.org/bugs/show_bug.cgi?id=312951
Therefore, I’m sticking with Eclipse Galileo PDT SR2 for now (works fine, with both xdebug 2.0.5 and 2.1.0).
Comment by Samuel Lampa — July 13, 2010 @ 4:34 pm |
Figured out now that I needed to use the latest version of PDT (2.1.0) in order for local variables to be properly tracked (You need to download it from the SVN server and compile it from source).
Comment by Samuel Lampa — July 13, 2010 @ 7:01 pm |
Thank YOU Samuel Lampa!
It works for me on Ubuntu 10
Comment by exor — August 30, 2010 @ 10:11 am |
I have a IIS/xdebug/Eclipse configuration.
It stops when I set it to stop at the first line. But then all my breakpoints doesn’t break the exectution proces… I’ve finally figured out that problem was in Eclipse project name – it doesn’t like a dash (‘-’) char in the project name/folders. So everything has been fixed with simple renaming of the project name.
Comment by Igor Kostin — October 18, 2010 @ 2:35 am |
BTW, I use the latest Eclipse Helios version and recommend everybody to update your Eclipse since there are many important fixes and improvements.
Comment by Igor Kostin — October 18, 2010 @ 2:37 am |
Good story.. you have to check Adult Toy Store.
Comment by theerotictoystore — December 3, 2010 @ 5:39 am |
thanks, it worked for me
Comment by Rocky — February 11, 2011 @ 2:40 pm |
I didn’t have the xdebug.ini settings so XDebug kept crashing whenever I would attempt to view a variable in Eclipse. Thanks for the tip!
Comment by Marlon — February 15, 2011 @ 3:52 am |
Thanks for the article. It was useful.
Comment by Merce — May 18, 2011 @ 11:04 am |
I use the latest Eclipse Helios version and recommend everybody to update your Eclipse since there are many important fixes and improvements.
Comment by adult toys — November 1, 2011 @ 5:21 pm |
прайс лист с наличием по материалам для наращивания, IBD.
рассмотрите его пожалуйста.
Цены Розница рубли, с доставкой по Москве. Скидки с первой закупки.
В личку могу отправить сообщение только до 5000 знаков, отправляю материалы IBD- остальные на Вашу почту, если сообщите.
Извините за беспокойство.
Email: 0458727@gmail.com
Цены розничные, для постоянных клиентов скидки.
–Гелевая технология
.ibd. Bonder Gel, 14 мл. 732,375
.ibd. Clear Gel, 14 мл. 732,375
.ibd. Clear Gel, 56 мл. 1559,25
.ibd. Clear Gel, 226 мл. 3945,375
.ibd. Builder Gel Clear, 14 мл. 732,375
.ibd. Builder Gel Clear, 56 мл. 1795,5
.ibd. Builder Gel Pink, 14 мл. 732,375
.ibd. Builder Gel Pink, 56 мл. 1795,5
.ibd. Builder Gel Ultra White, 14 мл. 732,375
.ibd. Builder Gel Ultra White, 56 мл. 1795,5
.ibd. Builder Gel White, 14 мл. 732,375
.ibd. Builder Gel Natural, 14 мл. 732,375
.ibd. French X-treme Builder Gel Clear, 14 мл. 732,375
.ibd. French X-treme Builder Gel Blush, 14 мл. 732,375
.ibd. French X-treme Builder Gel Blush, 56 мл. 1795,5
.ibd. French X-treme Builder Gel Pink, 14 мл. 732,375
.ibd. French X-treme Builder Gel White, 14 мл. 732,375
.ibd. French X-treme Builder Gel White, 56 мл. 1795,5
.ibd. Ultra Seal Clear, 14 мл. 784,35
.ibd. Ultra Seal Clear, 113 мл. 2263,275
.ibd. Intense Seal, 14 мл. 732,375
.ibd. Intense Seal, 236 мл. 3260,25
.ibd. Builder Gel Clear 95 мл. 2740,5
.ibd. Clear Gel, 30 мл. 1323
.ibd. Builder Gel Clear, 30 мл. 1323
.ibd. Builder Gel Pink, 30 мл. 1323
.ibd. Builder Gel Pink, 95 мл. 2740,5
–Гелевые наборы
.ibd. Introductory Gel Kit 1559,25
.ibd. Professional Gel Kit 4862,025
.ibd. Sweet Confection Gel Polish Kit 2268
.ibd. Precious Metals Gel Polish Kit 2268
.ibd. Holiday Gel Polish Collection 1677,375
–Гели для дизайна
—-Гель-лак
.ibd. Gel Polish Up All Night, 7 г. 420,525
.ibd. Gel Polish Extreme Black, 7 г. 420,525
.ibd. Gel Polish Autograph, 7 г. 420,525
.ibd. Gel Polish Tangerine Dream, 7 г. 420,525
.ibd. Gel Polish Glitter Shimmer, 7 г. 420,525
.ibd. Gel Polish Pamper Me, 7 г. 420,525
.ibd. Gel Polish Copper, 7 г. 420,525
.ibd. Gel Polish Rose Gold, 7 г. 420,525
.ibd. Gel Polish Holly Berry, 7 г. 420,525
.ibd. Gel Polish Stainless Steel, 7 г. 420,525
.ibd. Gel Polish Sun Ray, 7 г. 420,525
.ibd. Gel Polish Ruzh Оf Nuar, 14 г. 236,25
.ibd. Gel Polish Silver Bells, 7 г. 420,525
.ibd. Gel Polish Party Till Dawn, 7 г. 420,525
.ibd. Gel Polish Techno Ruby, 7 г. 420,525
.ibd. Gel Polish Cognac, 14 г. 236,25
.ibd. Gel Polish® All Terrain, 14 г. 236,25
.ibd. Gel Polish Titanium, 7 г. 420,525
.ibd. Gel Polish Gracial Mint, 7 г. 420,525
.ibd. Gel Polish Apricot Creme, 7 г. 420,525
.ibd. Gel Polish® Eternal Daydream, 14 г. 236,25
.ibd. Gel Polish® Tango, 14 г. 236,25
.ibd. Gel Polish® Chocolate Gloss, 14 г. 236,25
.ibd. Gel Polish® Rustic, 14 г. 236,25
.ibd. Gel Polish® Fairytale Romance, 14 г. 236,25
.ibd. Gel Polish® Glass Slipper, 14 г. 236,25
.ibd. Gel Polish® Spicy Terracotta, 14 г. 236,25
.ibd. Gel Polish® Natural Elegance , 14 г. 236,25
Comment by vikosha0458727 — December 21, 2011 @ 3:40 pm |
Thank you it worked for me
Comment by pavi2p — March 3, 2012 @ 10:26 am |
Доброе утро!
Comment by SashaMebel — March 26, 2012 @ 4:53 am |
Thanks a heap! Awesome guide!
Comment by acewolk — May 9, 2012 @ 11:34 am |
It’s nice guiedlines.Last 5 years i used dreamviewer for php devlopment.And many times i found difficulties.
Comment by uday Satardekar — June 29, 2012 @ 4:59 am |
I prefer Codelobster PHP Edition
It is my favourite free PHP debugger.
Comment by Ruslik — January 29, 2013 @ 12:53 pm |
Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just extremely wonderful.
I really like what you’ve acquired here, really like what you’re stating and the
way in which you say it. You make it enjoyable and you still care for to keep
it smart. I can’t wait to read much more from you. This is actually a great website.
Comment by Property And Liability Insurance — May 14, 2013 @ 12:13 pm |
Yes! Finally something about payday loan blog.
Comment by http://www.cangm.com/ — May 19, 2013 @ 6:02 am |
Excellent, what a web site it is! This blog gives valuable
information to us, keep it up.
Comment by url shortner — May 24, 2013 @ 9:31 pm |
For the reason that the admin of this website is working,
no question very shortly it will be famous, due to its quality contents.
Comment by laser spine institute — June 5, 2013 @ 6:02 pm |
I like the helpful information you provide in
your articles. I will bookmark your weblog and check again
here regularly. I’m quite certain I will learn lots of new stuff right here! Good luck for the next!
Comment by Canvas modern Art — June 16, 2013 @ 8:00 am |