Local and Remote PHP Debuging in NetBeans with Xdebug on Google Chrome (just like in Visual Studio)

Saturday 21st, May 2011 / 13:12 Written by
in PHP

Have you ever wonder how to debug your php projects just like it is done in Visual Studio?Well it is not that simple as in Visual Studio.NET where you just click “Debug” and all is set for you. You need to install and configure couple of things but that’s about it.
In this tutorial we are going to set xdebug for php on Ubuntu server and we are going to use Google Chrome as a browser in our debugging process.

Let’s setup server. Log in to your ubuntu box.
1. Install xdebug for php

sudo aptitude install php5-xdebug
sudo /etc/init.d/apache2 restart

2. Check installation

php -v

arturito@hokage:~$ php -v
PHP 5.3.3-1ubuntu9.3 with Suhosin-Patch (cli) (built: Jan 12 2011 16:08:14)Copyright (c) 1997-2009 The PHP GroupZend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

3.  Edit php.ini

sudo nano /etc/php5/apache2/php.ini

4. Stick these lines in:


5. Install Google Chrome xdebug extension:


6. In Chrome go to Tools>Extensions

7. Click on Options and add domains you want to be able to debug

8. Open NetBeans and go to Tools > Options > PHP

9. Now create new project as a test  and set the breakpoint.

10. Hit Ctrl + F5

Your browser will hang.

and you will be able to step through the code


If your webserver is not installed on your machine but it is on the separate one you should set xdebug.remote_host to the IP of your development machine.
For example I run ubuntu with apache in virtual box so I set
where is the IP of my Windows host OS where I have NetBeans installed.

  • Gixx

    Yeah! At last! After two weeks of time wasting, finally you give me missing link: browser extension. I just can’t understand, why is it so hard for others who succeeded in making these tools work together to write down: “Dude, without a browser extension you will fail.”

    You are the first one and I’m so glad! Thank you! :)

    • http://twitter.com/ButlerPCnet Michael Butler

      Yes a browser extension simplifies things but you don’t need one. You can use a javascript bookmarklet which turns On/Off your DEBUG cookie. search google for “xdebug php bookmarklet”

  • Jebbushell

    Doesn’t work for me.  Everything looks healthy.  No obvious errors. But stepping never gets enabled.  

    • Anonymous

      1. Did you enable the plugin for Chrome? The bug symbol at the end of the url bar should go green. 

      2. Are you sure that your ubuntu box can talk to your client? Is there anything blocking it like ubuntu firewall?

  • Dennis

    great ¡¡¡, it works fine for me, keep it up ¡¡¡

  • Sainthyoga2003

    not works for me

  • Sainthyoga2003

    not works for me

    • Anonymous

      Have you followed all instructions carefully?