Simple clear advice in plain English

Hands on: Debugging PHP on Windows

How to use Eclipse to debug your PHP scripts on Windows

PHP is a great web development language, but it can be awkward to test and debug. Unlike ASP.Net and Visual Studio, there’s no standard PHP IDE, and developers take a variety of approaches.

The old trick of using functions such as echo or var_dump, to output current values to the browser for testing, still works, but it is more arduous than using a proper debugger, especially when you need to trace a complex execution path.

It is worth setting up a PHP debugging environment on your own machine, though, so you can develop and test in convenience and safety.

The option I’ve picked for this tutorial is Eclipse, the free tools platform best known as a Java IDE. Eclipse has a huge range of add-ons, one of which is the PHP Developer Tools project. Eclipse is not the whole answer, though. To set this up, you need Wamp (Windows, Apache, MySQL, PHP), a PHP debugger and Eclipse.

Preparation
There are a few tools that are useful for working with Linux or Mac files on Windows. When extracting archives, the tool that is built into Windows sometimes has problems with Unix archives and doesn’t support all the formats you might need. However, Grab 7-Zip works perfectly.

Another annoyance comes when you try editing Linux text configuration files in Notepad. Windows has another way of dealing with line endings and runs all the text together. Install Notepad++ or another suitable editor.

Java
Eclipse won’t run without Java, and it makes sense to get the official Sun version. Eclipse recommends a Java 5 JRE (Java Runtime Environment), but in my tests, the latest version 6 worked fine.

Reader Comments

   

Add your comment

All fields must be completed. Your email address will not be displayed or used to send marketing messages.

All messages will be checked by moderators before appearing on the site.

See our Privacy Policy for more information.

Related articles

screenshot-of-getsimple-cms

Run your own website with GetSimple CMS

An excellent content management system for beginners that doesn't require a database

Choosing a home network server

There are many things to consider when adding a server to a network. Alan Stevens explains

Hands on: SQL injections

Prevent SQL injections with the help of PHP

Question & Answer

Q.How do I stop Windows 7 search?

> Read the answer

Q.Is it a genuine call from Microsoft?

> Read the answer

Q.How can I turn Autoplay back on?

> Read the answer

No matching document

Great benefits for subscribers!

Poll

Which is your preferred web browser

Jargon Buster

Computing terms explained in plain English

VoIP

Voice over IP. The routing of voice conversations over the internet, which is cheaper than the telephone...

Great shopping deals from Computeractive