Tuesday, July 22, 2008

Setup Netbeans PHP Debug Environment with XDebug

Netbeans IDE is a free, open-source Integrated Development Environment for software developers. You get all the tools you need to create professional desktop, enterprise, web, and mobile applications with the Java language, C/C++, Ruby and PHP. NetBeans IDE runs on many platforms including Windows, Linux, Mac OS X and Solaris.
The NetBeans IDE Early Access for PHP was released in April at the same time as NetBeans 6.1. Milestone 1 of NetBeans 6.5 now contains all features introduced in this release.

Setting up Netbeans PHP environment with XDebug is easier compared with Eclipse IDE. The most important step of setting up PHP with Xdebug in Netbeans is to configure PHP and XDebug, here is how:

  1. Check your PHP version by executing:
    php -v
    Now you will get something like:
    PHP 5.2.2 (cli) (built: May 2 2007 19:18:26)
    Copyright (c) 1997-2007 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
  2. Now you go to XDebug.org to download XDebug module corresponding to the PHP version installed on your machine as shown above, and put XDebug module into PHP's extension directory or somewhere else
  3. Now add the following to your php.ini which is normally under your PHP installation directory
    [xdebug]
    xdebug.remote_enable=1
    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=9000
    xdebug.remote_handler=dbgp
    zend_extension_ts=D:\tools\php\ext\php_xdebug-2.0.3-5.2.5.dll
  4. Now start up Netbeans 6.5 M1 or above (as of this writing, Netbeans 6.5 M1 is just available). You can download it from http://www.netbeans.org
  5. Go to Tools -> Options menu to bring up Netbeans Options dialog
  6. Select Miscellaneous button on top of the dialog and Click PHP tab, you will see the following

Basically you don't need to do anything unless you want to change some settings such as where php.exe is located at, how do you want to output the result, debugger port (default to 9000), whether you want debugger to stop at the first line of the php files etc

You may need to write a simple PHP script to test if it's working locally, if so then your installation is fine. Otherwise, make sure you follow the above steps

That's it. Simple and easy.

My Settings: Netbeans 6.5 M1, PHP 5.2.2 and XDebug

3 comments:

ι€†ζ—Άι’ˆ said...

thx,it works!

Avirup's Blog said...

HI...

I have done all the thing...

But in netbeans nothing is coming to write the port no.

Did I need to install x debugger ..pplz tell the procedure!!!

clod said...

Codelobster IDE works better with xDebug