The next milestone of the chart project will require some analysis and manipulation of data sets. Seeing as how I am new to PHP, my intuition tells me that the better part of judgment is not to fly blindly into it …
Unfortunately, setting up Eclipse to debug PHP code in a reasonable manner is nearly as complex. I had been using XAMPPlite for development up until this point. I was using version 1.7.3 which uses PHP 5.3.1. In order to debug in eclipse I had to go out seeking a debug binary here. After a long bit of trial and error I found that this binary was no longer supported. So here’s the short step by step:
- Download Eclipse IDE for Java EE Developers
- Start Eclipse → Help → Install new software
- Work with all available sites, search for ‘PHP’Note that the PDT can show up multiple times but you only need to select one, click next, install it.
- Now go to download the version of XAMPP appropriate for you. I found that the installer worked great.
- The default installation instructions worked perfectly for me
- If you are trying to install WordPress on top of this, then I think that this tutorial might be useful
- I needed to migrate from my XAMPPlite install to my new XAMPP installation.
- Copy C:\xampplite\htdocs\YOURSITE to C:\xamp\htdocs\YOURSITE
- Copy C:\xampplite\mysql\data\wordpress to C:\xampp\mysql\data\wordpress
- Note that this will also be useful for copying in databases for other reasons!!!
You should have XAMPP running a live copy of WordPress for you at this point. The next step is to configure the debugger.
- Go to XDebug and download the appropriate version for you. With XAMPP 1.8.1 this corresponds to PHP version 5.4.7 and XDebug 2.2.1.
- Your XAMPP installation may come with the latest executable. But to be sure, install this one into C:\xampp\php\ext\
- Open C:\xampp\php\php.ini and find the [Xdebug] section.
- Edit it to look like this:
zend_extension = “C:\xampp\php\ext\php_xdebug-2.2.1-5.4-vc9.dll”
xdebug.profiler_append = 0
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = “C:\xampp\tmp”
xdebug.profiler_output_name = “cachegrind.out.%t-%s”
xdebug.remote_enable = 1
xdebug.remote_handler = “dbgp”
xdebug.remote_host = “127.0.0.1”
xdebug.trace_output_dir = “C:\xampp\tmp”
- Where your zend_extension obviously corresponds to the file you just downloaded.
- Edit it to look like this:
- Restart the Apache service through the XAMPP control panel. (Now would be a good time to verify that xdebug is loaded properly by browsing to http://localhost and clicking on phpinfo(). xdebug is loaded properly if you see a section detailing xdebug configuration parameters).
- Load your WordPress install into Eclipse as described in this guide
- Right-click on your project in the Project Explorer in Eclipse → Debug As → Debug Configurations
- Double click on PHP Web Application to create a new debug configuration
- Set the server debugger to Xdebug, Create a PHP Server as follows:
- I choose to disable break at first line and to auto-generate debug URLs. Of course you need to modify these instructions to suit your own site, but my final configuration looks like this:
- Click Apply and debug
- If all went well then you should now be looking at a prompt to switch to the debugging perspective and then this:
There are lots of moving parts here, so don’t feel bad if you don’t get it working on your first try. Most errors lie in the following areas:
- WordPress database permissions. If you can’t get this working properly, do a fresh install of wordpress and delete the previous entries into MySQL.
- PHP configuration. Specifically php.ini — the configuration inputs for this file have changed quite a bit over the past few versions. I can vouch for the configuration / version above.
- XDebug version. There are many different versions of this dll binary. Again, I can vouch for the one above but in case you think yours may not be working. A quick way to check to see if it is being loaded by Apache is to go to http://localhost and click phpinfo(). You should see a table for xdebug if it is loaded properly.
Now that I can trace data structures to and from my scripts, I can verify that data is being pulled from the DB and plotted correctly.