Debugging PHP with NetBeans

How easy is it to make debugging working for PHP code? With NetBeans no problem! Only 5 easy steps!

  1. Download NetBeans 6.9 (although I am using the old 6.8)
  2. If you are on ubuntu installing xdebug is a one liner:
    sudo pecl install xdebug

    write down the path to xdebug for me it is

  3. add the following to your php.ini (on my system at /etc/php5/apache2/php.ini):
  4. apache2ctl restart.
  5. Set a breakpoint via clicking on the line number. Then right click the project->Debug (Select ‘Server Side PHP’). Now you should see sth. like this:

    Check the ubuntu thread, the xdebug site and the netbeans site if you have still problems.

Now you should be able to execute your code step by step with F8, continue with F5 and e.g view the content of variables: select parts of the code and see the result:

And a lot more feature like inspecting deep objects with the ‘Variables window’:

This is not as mature as the Java Debugger but a better then printing echo statementsūüėČ