The Well-Tempered PHP Developer

Eclipse, with some plugins added to the mix, provides a full environment for PHP developers.

Can there be any errors if the testing techniques mentioned above are applied? Unfortunately, there are well-known theorems showing that no amount of testing can ensure program correctness, so now and then, you still will find yourself trying to figure out what went wrong. Classically, PHP programmers use print statements—usually, a die(...) instruction—but that's a cumbersome way of doing it. Furthermore, changing a program in order to see what happens (even if the change is an innocuous printing command) is not a good idea; you can make things even worse accidentally.

Although some languages (notably Java and Smalltalk) always have had quite good debugging environments, allowing you even to trace the code on a sentence-by-sentence basis, setting breakpoints, examining variables and so on, PHP programmers too often have found themselves with the short end of the stick.

There are basically two options: XDebug and DBG. XDebug is up to version 2.0.3 (from April 2008), and it's fully open source. On the other hand, DBG has two versions: a free one (at version 2.15.5) and a commercial one (at version 3.1.11). XDebug supports PHP 5.3, and DBG works only up to 5.2. For both programs though, the main sticking point is configuration, which is far too long to include here (see Resources). After you get the debugger to run, you will be able to debug your code easily; it's a pity that the installation procedure is such a chore.

Version Control (VC)

Version control (also known as revision control or source code control) is a must for large-scale, multi-developer projects, but it also offers significant advantages even for standalone work. The first time you thrash your code and manage to restore it or find what you changed thanks to your VC system, you will fully appreciate version control.

Basically, all VC systems allow you to store documents and record the changes made to them. VC systems allow you to inspect not only the latest version of any document, but also to go back to previous ones and work out the differences between any two versions. Explaining version control in all its details is beyond the scope of this article.

Many different version control programs are available: BitKeeper, Git, Mercurial, CVS and SVN, but not all of them have Eclipse plugins. At the very least, both CVS and SVN can be used with PHPEclipse, but I prefer the latter, because it allows for moving files; CVS doesn't.

PHPEclipse can connect to SVN repositories by using either Subversive or Subclipse. Note that at the time of this writing, both plugins are assured to work only with Eclipse 3.3 (Europa) and not with 3.4 (Ganymede). After installing one of those plugins, you will be able to download a working copy or synchronize your work with the repository, simply by right-clicking on the project and selecting the Team option. The results of a synchronization operation will show in a separate console and usually will consist of files that you should download (others have modified them and you are not up to date), files you should upload (only you have modified them) and conflict files. Clicking on a conflicting file will bring up a file comparison window (Figure 6), highlighting the differences between your code and the already uploaded code. How to merge that code is up to you.

Figure 6. With a synchronization conflict, you need to analyze the differences between versions and decide what to do.


Eclipse can provide a great environment for PHP development, with all the necessary tools for modern, agile development. Take the time to learn all the existing functions, and you will find yourself creating good quality code in a faster, surer and easier way.

Federico Kereki is an Uruguayan Systems Engineer, with more than 20 years' experience teaching at universities, doing development and consulting work, and writing articles and course material. He has been using Linux for many years now, having installed it at several different companies. He is particularly interested in the better security and performance of Linux boxes.


Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
On Demand
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot