Monthly Archives: November 2013

This article: HowToConfigureXDebug – NetBeans Wiki  is helpful, but you may need a bit of help to get over the top, so I have put a few hints in here in hopes to save others some hours I already spent.

I have now installed WAMP (Windows / Apache / MySql / PHP) and Netbeans several times dues to several laptop and hard drive failures, and kept getting stuck on this issue, forgetting the solution. The web pages I could find mostly show the correct information, however, some are old, and refer to old configurations, and none I found were completely correct.

I have found the fastest way to get up and running if you are going to program PHP under apache on Windows is to use the WAMP stack, which goes in smoothly.

Getting debug running is another story. Once you have installed WAMP, you need to do several things in order to get XDebug running. I am going to take you through the process (let me know if I have missed something – I am not an expert, just sharing scars so other can avoid!).

(This tutorial assumes that you have already downloaded WAMP from Bitnami’s site and run the install.)

1. Change the port to the one you wish to use. Quite often in a windows environment you will want to use a port other than 80 for PHP debugging (I am using localhost 80 for .Net and Visual Studio debugging). If you open the Apache configuration (which the Bitnami WAMP management program will open for you with a click):

Bitnami1

you will find the port in this configuration in two places – here:

ApacheConf1

and here:

ApacheConf2

2. You then need to edit the php.ini file (for me, located at C:\BitNami\wampstack-5.4.21-0\php) to include the xdebug dll – there are lots of places out there that tell you things like there being a php.ini in the bin folder (which there isn’t), and old versions of the editing that are required – these have been taken care of since then and changed.

One great thing about WAMP is that the correct xdebug file is already installed and ready to enable.

You will also find a great little tool out there that helps you determine if XDebug is properly installed. But you do not need it if you use Bitnami WAMP. Setting the config as follows below (you have to match your install – I used the default which I highly recommend). If you are using the version of WAMP I am using, you will find this code near the bottom of the file commented out (using semicolons) and need to uncomment it and correct the dll file reference. The dll should already be in there ready to go. The full path and forward slashes are required.

[XDebug]
;; Only Zend OR (!) XDebug
zend_extension="C:/BitNami/wampstack-5.4.21-0/php/ext/php_xdebug.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp

This will then activate XDebug. There are other helpful settings in this file for development purposes (like logging and caching), which are outside of the scope of this post, but are easily Googled.

3. Restart the Apache server:

Bitnami3

4. Verify that your website works by navigating to:

http://localhost:8888

You should get the default index.html file’s output saying

It Works!

in large type. This means Apache is serving up an html file from the htdocs directory (C:\BitNami\wampstack-5.4.21-0\apache2\htdocs by default).

5. Now create and edit an index.php file in the same apache htdocs directory and type

phpinfo();

and then save it in that same directory.

4. When you now navigate to:

http://localhost:8888/index.php

The php engine will echo out it configuration info. XDebug should show up in the output in two places.

here (near the top):

phpinfo1

and here (near the bottom):

phpinfo2

I decided to post after the fourth time of getting stuck on this because the information is not all in one place and the most complete info is not current.

Happy PHPing!

 

Advertisements