Debugging CodeIgniter Project using Xdebug and Netbeans

Finding the right way to debug PHP projects has always been a hot topic. Primitive solutions like `echo`, `print_r`,`var_dump` has always been the power tool 🙂 for my type of ppl .  Let us forget those painful nights and go to a quick debugging solution with Xdebug and Netbeans 6.8; in a 1-2-3 step guide for CodeIgniter.

What i am expecting from you:

  • You already have a running web server [ Xampp/WAMP/ Uniform server ]
  • You know how to install Netbeans IDE 6.8 or it’s already running in your environment
  • You know what is CodeIgniter
  • You are not a complete Newbie

# STEP – 1

First add extension Xdebug in PHP. Download latest stable Xdebug version from Follow the procedures. If you are lazy like me and don’t want to read the whole thing [it’s a bad habit 🙂 ] copy the following settings and put at the end of your php.ini by not forgetting to change the path 🙂


Note: If anything messes up later; come back and study those links over and over till u understand the whole thing.

# STEP – 2

Configure CodeIgniter to accept ‘?XDEBUG_SESSION_START=netbeans-xdebug’. You can follow one of my post or check in codeigniter forums for accepting GET data in CodeIgniter.

Start Netbeans IDE. Goto Tools >> Options >> PHP >> General: and check for settings in Debugging section. By default the port should be 9000 and Session-ID ‘netbeans-xdebug’.

#STEP -3 [ FINAL 😀 ]

Let’s say, You have installed a ‘test’ CodeIgniter application in your web server. Now add that application as a project in Netbeans 6.8 . Goto Project properties by right clicking on the project ‘test’.  Now go to ‘Run Configuration’ and click ‘advanced’  select ‘Ask Every time’ in Debug URL.

Now Open your ‘welcome’ controller and press ‘Ctrl+F5’ which will request for the URL:

specify url

insert ‘http://localhost/test/’  and press ‘Ok’.  Next select `Server side PHP`.

Clicking in ‘Debug’ button will open ‘http://localhost/test/?XDEBUG_SESSION_START=netbeans-xdebug‘ In you default web browser.

Now check in status bar for:

And check in toolbar for:

If those 2 shows up then u have successfully installed Xdebug+Netbeans. Your IDE is ready to do some debugging. Take your cursor over a line on index function of welcome.php; press ‘F4’ this will execute php scripts till that cursor. Dont worry if index.php is opened up focusing on first line.

Now You can watch for variables or step into functions or step over. You can check your code line by line.

Read this link which have brief discussion on what options you have for Debugging :).

My counting on steps could be wrong 🙂 .. bt it looks nice 1-2-3. I tried not to explain a lot; so for more details study provided links.  I hope this will make your life more easier. Enjoy !!

13 thoughts on “Debugging CodeIgniter Project using Xdebug and Netbeans

  1. Awnish Kumar says:

    We are a web development company and is developing websites for more than 5 years and was looking for these type of debugging software. It helps me to debug the code and hence we are now faster than earlier

  2. Goody says:

    Debug process works… at least Step Over/Into/Out. For some reason “Continue” doesn’t bring me to next breakpoint (should it bring me?). “Run to cursor” doesn’t work too… but that is not the main problem for me..

    Here is the main problem:
    In the end of the debug process browser pops up 404 error
    “404 Page Not Found
    The page you requested was not found.”

    Here is CI log message
    “ERROR – 2010-07-02 12:52:06 –> 404 Page Not Found –> local/XDEBUG_SESSION_START”

    Any ideas?

    Thanks in advance!

  3. Goody says:

    Thanks. It works! A bit strange but works.. maybe that is because I am using debugger at first 🙂

  4. Daniel says:


    Followed your tutorial. The explanation’s pretty good but unfortunately I’m still getting the same old 404 page at the beginning of debug and for some reason NetBeans debugger only cycles through my config.php page (ci config file) and that’s it.

    I’m on Mac OSX, debugging with Xdebug in FF3.6, NB latest vs. using Mamp. The debugger *is* working, but not ‘doing anything’ 🙂

  5. Daniel says:

    tohin –

    Thanks for offering 🙂

    Actually I’ve found the perfect solution, and it doesn’t required a tenth of the work described in this post. Now this may be my own ignorance talking, as I don’t entirely appreciate the impact of the steps suggested, or perhaps the post/suggestions are outdated? Regardless, all I can say is that it took me exactly 5 minutes, start-to-finish.

    Netbeans works flawlessly with Firefox/Xdebug. No 404’s, no problems, no hassles. The debugger cycles through the code perfectly! Oh and rather then selecting the run/debug “Ask Every Time” option, you can simply turn it off altogether. That way it doesn’t recreate a browser tab every time you start/stop a session, and you can easily suspend/continue debugging from the Xdebug button within Firefox.

    After spending countless hours getting this stupid contraption to behave, I figured another 2 wouldn’t hurt. So I sat down and wrote a detailed post describing each and every step, start-to-finish, from scratch. And from some of the follow-up replies (from more knowledgeable/Windows folks) it seems that it applies just the same to Windows.

    If you’re interested, have a look:

    Thanks for the offer! 🙂

  6. tohin says:

    That’s a better solution. If an addon removes the repetitive tasks so why should we not use that. Thanks for the comments and thread. Will give it a go for sure.. Thanks .

  7. freddy sidauruk says:

    Hey there, nice to read it but i use notepad ++ for develop system, i’m not ussual using netbean, is there debugging for notepad ?

    Thanks for nice respon brother 😀

Leave a Reply

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

You are commenting using your 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