The Well-Tempered PHP Developer
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 (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.
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.
PHP Home Page: www.php.net
Eclipse Home Page: www.eclipse.org
Eclipse Download Page: www.eclipse.org/downloads
IBM's Description of Ganymede's New Features: www-128.ibm.com/developerworks/library/os-eclipse-ganymede
The IcedTea Project—a Free Implementation of Java: icedtea.classpath.org
Sun Developer Network Page: java.sun.com
PHPEclipse Latest Version Update: update.phpeclipse.net/update/nightly
PHPEclipse Full Documentation: docs.schuetzengau-freising.de/modules/xdocman/index.php?doc=xo-002
The Last Craft (PHP Testing): www.lastcraft.com
SimpleTest for the Eclipse Update: simpletest.org/eclipse
PHP Debugging: www.ibm.com/developerworks/library/os-debug
Configuring XDebug for PHPEclipse: dev.phpeclipse.com/wiki/XDebug_and_PHPEclipse
DBG Installation Guide: dd.cron.ru/dbg/installation.php
PHPEclipse DGB Configuration: docs.schuetzengau-freising.de/modules/xdocman/manual.php?doc=xo-002&id=sec.install_dbg&file=ch01s05.html
The Subversive Plugin for Using Subversion: www.eclipse.org/subversive
Subclipse, an Alternative for Accessing SVN Repositories: subclipse.tigris.org
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.
- Nmap—Not Just for Evil!
- Resurrecting the Armadillo
- High-Availability Storage with HA-LVM
- March 2015 Issue of Linux Journal: System Administration
- Real-Time Rogue Wireless Access Point Detection with the Raspberry Pi
- DNSMasq, the Pint-Sized Super Dæmon!
- Localhost DNS Cache
- Days Between Dates: the Counting
- The Usability of GNOME
- Linux for Astronomers