Debug : xDebug with CodeIgniter over LAMP

Hello friends,

How is going on? Hope everyone is fine. This days I am fascinated with PHP, but still I missed my VB6 and .NET experience as those have a built in debug system. And you know debugging is one of the best way to confirm about what is happening by your code. So I searched for debugging with PHP and found Xdebug is the the solution for PHP.

Couple of days ago I installed Xdebug on a Fedora 19 OS in order to use it with Netbeans 7.3 It took me lot of time to understand how it works. So I share with you how did I managed to have it working:

Install Xdebug:

sudo yum install php-pecl-xdebug.x86_64

Add this lines to php.ini at the end of the file:

sudo vi /etc/php.ini

zend_extension=/usr/lib64/php/modules/xdebug.so xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000

Add the same lines to xdebug.ini file:

sudo vi /etc/php-zts.d/xdebug.ini

xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000

Allow port for Xdebug

sudo semanage port -a -t http_port_t -p tcp 9000

Now find your netbeans.conf file in your system:

sudo find / -name netbeans.conf

Now, open up the file and add the text “-J-Dorg.netbeans.modules.php.dbgp.level=400″ in netbeans_default_options so that the line looks somewhat like this:

netbeans_default_options=”-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dnetbeans.logger.console=true -J-ea -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true -J-Dsun.awt.disableMixing=true -J-Dnetbeans.extbrowser.manual_chrome_plugin_install=yes -J-Dorg.netbeans.modules.php.dbgp.level=400″

Restart both NetBeans IDE and apache:

sudo service httpd restart

Let’s say, You have installed a ‘test’ CodeIgniter application (As CodeIgniter is my favorite framework :P ) in your web server. Now add that application as a project in Netbeans. 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.

Bingo!!! Now you are ready to debug your PHP application over CodeIgniter. Just make a breakpoint on your desire line and click over Debug Project or press Ctrl + F5. You will get your step by step debugging session running with your default browser. Press F7 or F8 to start your line by line debugging.

Happy coding with debugging buddies :)

(Visited 14 times, 1 visits today)

Leave a comment

Your email address will not be published. Required fields are marked *