In this post I’m going to explain how to install PHP in Windows and how to set it up so you can also debug it. We’ll use XDebug and NetBeans in order to make it work.
First we should install Apache, MySQL and PHP. One way to do it is downloading XAMPP (I suggest the XAMPPLite, which has the main components) or EasyPHP. You can also do the download of each component separated, but it takes a little longer. As the goal of this tutorial is to do a local installation, only for development, I’ll not go in detail about it.
Proceed with the installation of XAMPP (I’ll focus on this one in the rest of the tutorial) or EasyPHP. I’ll not give further instructions because you only need to follow the installer. One note about XAMPP is that it will ask for a installation directory, where it will extract all files inside a sub-folder xampp, so if you select the root directory “C:\”, XAMPP will be installed into C:\xampp (or C:\xampplite).
The next step is to choose a IDE (Integrated Development Environment). Two good options, in my opinion, and free, are Eclipse and NetBeans, in their PHP versions. Besides usual stuff, both allow you to debug your PHP projects! So you don’t need to “echo” things in the screen anymore.
Proceed with the IDE installation. I installed both in my PC, but I’m using NetBeans, which I’ll use in the rest of the tutorial. An important configuration in NetBeans is the inclusion of the base PHP path in all projects, allowing auto-completion for standard PHP functions. In order to do that go into the menu Tools > Options, select the PHP options (1), insert the PHP command line (2) and add the folder (3) in the global inclusion path. Select the PHP path (in my case C:\xamplite\php) and confirm.
To enable the PHP debugger we need to install XDebug. It’s only a DLL that we need to add to the PHP settings. It’s important to choose the correct version to download. In order to know that you need to create a new PHP document and add a phpinfo() command. Check the PHP version (1) and build (2):
In my case, the PHP version is 5.3 and the Build is VC6, so I downloaded XDebug 5.3 VC6 (32 bit). Do the download and save it in your preferred folder (I saved it in C:\xampplite\xdebug). The last part is the PHP ini file. Go to the installation directory of XAMPP, sub-folder PHP and edit the file “php.ini”. Include the following lines in the end of the file:
Remeber that all directories should be changed according to your installation.
That’s it! You are ready to debug it.