Home > NetBeans, php, X-Debug > setting up php , xdebug and NetBeans

setting up php , xdebug and NetBeans

As developers,  we often come across with code debugging.   When it comes to debugging, my preferred option is to  utilize the facilities given by the IDE (In my case its NetBeans (6.9.1)). I find it more easy, accurate and useful way of investigating the program flow rather than printing lines in the code and having looking at the server log.

Today I wanted to debug one of my php codes. As I’m fairly new to php I haven’t used any debugging mechanisms. So I had a little googling and  found out the most preferred way is to  have x-debug setup with NetBeans.

even though the setup is fairly easy, I had to make use of several resources in several different locations. So I thought of summing up everything in an one place will help someone.

For this guide, my set up is as follows

I’m on linux, with apache2, php5 and NetBeans (6.9.1) .  I assume you all have php running on your apache server

Ok lets starts.

1 - download the xdebug (http://www.xdebug.org/download.php).  
make sure you download the correct (or most matching) source.  (I downloaded the source file)

2 - extract the source  file to any directory you want and browse to 
that directory

3 -  while you are inside that xdebug directory type 'phpize' in your console.  
you should see something like following

Configuring for:

 PHP Api Version:   20041225

 Zend Module Api No:      20060613

 Zend Extension Api No:   220060519

But if at all you get an error like 'bash: phpize: command not found' that means you are missing the '
php-devel' package. to install it run 'apt-get install php5-dev' as root

4 - Once done run ./configure 
5 - and make and make install (building the xdebug is their in the README file)
6 - after you run the above command you will get 'xdebug.so' which is under <your xdebug folder>/modules
7 - copy that in to any place you want.
8 - then open-up your php.ini file
    if you cant locate this file, best way is to create a php file in any name (in my case index.php) and add the 
following php code to it. <?php phpinfo(); ?> , then view it using the browser. that page should display where is your
active php.ini file is located. 
9 - open that file and add the followings

zend_extension = "/home/sameera/tools/web/xdebug/xdebug.so"

**** zend_extension path should be same as the path you have your xdebug.so
Thats it. restart apache and load your php.ini file. Then you should see a separate section for ‘XDebug’. By this time you should
be able to start debug your applications with NetBeans.

  • open NetBeans
  • open your php prject
  • add a break point
  • run your project in debug mode
Categories: NetBeans, php, X-Debug
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: