configure xdebug windows netbeans
How to configure xdebug on Windows for NetBeans
Xdebug is a handy tool to debug PHP based project and work seamlessly with NetBeans and eclipse IDE. There are add-on and plugins available for Notepad++ and Sublime editor to enable Xdebug based debugging.
This article is focused on how you can configure your Apache 2.x, install and configure Xdebug and debug your PHP project on NetBeans in Windows environment. And in last section we will show you what additional change you may need to make to debug your codeigniter based application.
Let’s start the process with downloading the Xdebug right for your PHP version. You may need to know which PHP version you are on, weather it is Thread Safe or Non Thread Safe and are you using 32bit or 64bit PHP version. Based on these three points you can decide which Xdebug version you need to download. Phpinfo() function would provide you all necessary information about your PHP version and so on. Visit Xdebug download page to download the plugin.
Here is the snapshot displaying Xdebug library for various PHP versions. You can select the desired and download it.
If you find it hard to gather all the details like PHP version, TSF or Non TSF and 32bit/64bit then there is an easier way available. It is known as custom installation instructions offered by Xdebug which suggests which version of plugin you should download based on your phpinfo() output.
Visit Xdebug page, now copy the output of your phpinfo() page(Ctrl + A and Ctrl + C) and past it into the box below like following image.
Once you past your phpinfo content, you may receive output something like shown in image below. Please do note I already have installed and configured Xdebug on my machine.
It reads every required piece of information from your phpinfo() output and suggests you a plugin version that you need to download and configure on your machine.
Once you have matching version of Xdebug downloaded into your machine, now is the time to place the plugin to required directory and configure the php.ini file.
First find the PHP directory on your WAMP/XAMPP setup. You need to locate the ext directory underneath. Once you located the directory past the downloaded Xdebug dll file into the ext directory. I am using custom Apache x64bit, PHP x64bit and MySQL setup on top of Windows 7 x64. And my PHP directory located under the C: drive. Following snapshot shows the ext directory under my setup.
Now open the php.ini file for further configuration. I prefer to use Notepad++ for configuration files as it offer flexibility in search, replace and syntax coloring. You need to add following lines at the end of your php.ini files.
You need to change C:phpext this line with you actual path to ext directory under PHP and plugin name php_xdebug-2.4.0-7.0-vc14-x86_64.dll with your downloaded plugin file name.
Once done, restart your apache server/service and check phpinfo() output and look for xdebug. If configuration was proper you should be able to see the output.
If you already have added php to your environment variable then this process will be much easier. Open command prompt (cmd) on your machine and fire-up php -v this will display PHP version along with Xdebug version. Like below.
Configure Xdebug for Codeigniter
If you want to debug codeigniter project you may need to add another line to php.ini file as codeigniter is MVC framework and every requests comes to routing system and then desired files and methods executed. So open your php.ini and add following line.
Restart the apache server/service and you are good to go.
Configure Xdebug for NetBeans
Open NetBeans Options by pressing Tools -> Options. Do check you have Debugger Port: 9000 and if you don’t need un-check Stop at First Line.
Debugging is developers most favorite weapon to trace out the bug and debug the flow. Many novice PHP programmers are not aware of debugging PHP project how how to configure xdebug on windows. This might help them get started and help them debug their future project codes. If you find this article helpful do share.