Figuring out how to configure NetBeans, xdebug, PHP, and Apache to enable debugging did not come by easily despite the myriad references available online. However, most (if not all) of them are outdated and inaccurate. As a result, they tend to obscure a rather simple configuration or how-to.
Software Applications Used
- WinXPSP3 on a virtual machine (e.g., VirtualBox)
- XAMPP 1.7.7
- Microsoft Visual C++ 2008 Redistributable
- Netbeans-7.0.1 For PHP
- Jdk 1.6 update 21
Install XAMPP, C++ binaries, JDK1.6u21, and Netbeans 7.
Step 1 – Configure PHP and start Apache
Add the following line in php.ini:
1 2 3 4 5 | zend_extension="C:\xampp\php\ext\php_xdebug.dll" xdebug.remote_enable=1 xdebug.remote_handler="dbgp" xdebug.remote_host="localhost" xdebug.remote_port=9000 |
Step 2 – Create a PHP project in Netbeans
Step 2a – Choose PHP Application
Step 2b – Choose PHP5.3
Step 2c – Local Web Server refers to our installed Apache
We will use just one PHP page
Step 3 – Put some codes in index.php and place some breakpoints
Step 4 – Test the code
Step 5 – Configure NetBeans
Step 6 – Debug Code
Debug some codes.