Frustration can quickly set in when you are dealing with menial and often repetitive tasks such as manual code testing and deployment, yet you strive to become a more efficient programmer by staying DRY. So why not extend that quest to other parts of the application lifecycle, streamlining and automating such tasks? In this article I'll introduce you to ten PHP development tools that will help you do exactly that, leaving you with more time to concentrate on building great websites.
Testing is a crucial part of the application development process, yet many developers give it short shrift because the task can be enormously time-consuming, plodding and error prone. To combat these issues, automated testing tools give developers the ability to write a series of testing scripts, which can be easily executed on a whim or even according to a predefined schedule. These tools also often provide a reporting feature, which details the outcome of each test run.
PHP developers have long had a great automated testing framework at their disposal known as PHPUnit. Based on the popular code-driven approach to testing known as xUnit, PHPUnit allows developers to actually write tests using familiar PHP syntax, and then execute these tests using a simple command-line utility. You can even integrate PHPUnit into continuous integration tools such as phpUnderControl (discussed further later in this article).
As a Web development project's complexity grows, developers face a number of deployment tasks that go beyond merely transferring files from the development to production server. Avoiding transferring development-specific files such as graphic templates, dealing with server-specific file permissions and configuration parameters such as database connection usernames and passwords, and figuring out how to revert changes quickly should the deployment not go as expected are all issues repeatedly faced by developers when deploying a site.
To combat these issues, developers employ build systems, which cannot make the file-transfer process much more efficient by synchronizing only those files that have changed. Build systems are also capable of following highly customized deployment procedures, which can vary according to the environment you're targeting. If you're not currently taking advantage of such a system, check out Phing, a build system modeled after the Apache Ant project. Supported on all major platforms -- Windows included -- Phing tasks can be easily configured using a simple XML syntax, and can manipulate the server file system, integrate with CVS and Subversion, and even create PEAR packages from your custom libraries.
On more than one occasion I've promoted the benefits of using version control to manage your source code. Version control brings a number of advantages to any project, including the ability to experiment with code branches, roll back unwanted changes, determine which team member most recently changed a particular file, and monitor progress through logging. Although many open source version control tools are widely used, Git is the current darling of the day and happens to be my personal tool of choice.
Part of the reason for Git's rise has to do with a third-party service called GitHub, which offers users an impressive array of repository hosting services. GitHub relieves development teams of the need to manage a server repository locally and even offers free hosting services for open source projects, with a negligible fee structure in place for commercial hosting. Having quickly surpassed 1 million hosted repositories, GitHub presents a tremendous value for developers seeking to shift otherwise costly and time-consuming administrative tasks to a capable third party.
While using automated testing tools such as PHPUnit will help you catch mistakes after the code has been written, sometimes you'll need some extra assistance in determining the cause of these problems. Many PHP developers rely upon a great open source debugging tool named XDebug, which can help you to examine the status of your code by providing utilities for tracing execution, profiling code performance, reviewing object contents, and much more.
Although you may very well be as unique and special as your mother claims, chances are that the code you're currently attempting to write has been cranked out by other developers countless times before. To help developers quickly surpass shared obstacles, PHP developers regularly contribute to the PHP Extension and Application Repository, better known as PEAR. Hosting 560 packages, which can offer turn-key solutions to problems such as caching, encryption, user authentication, and payment processing, chances are you'll find a PEAR package that suits your "unique" needs.
To help manage your PEAR packages, you can install the PEAR package manager, which provides a command-line interface to installing, upgrading and deleting packages.
Like the Editor Wars, arguments over coding conventions remain bitter. Even so, the PEAR Coding Standards seem to have gained a foothold within the PHP community, offering a sane approach to conventions (which I personally employ in my own projects). However, it can be easy for you or a team member to depart from these conventions, resulting in inconsistent code.
There are few tasks more frustrating than attempting to decipher poorly documented source code, even if it's code that you personally wrote some time ago. Yet like testing, documentation remains one of those tasks that developers tend to avoid at all costs. To alleviate the pain, consider using an automated documentation framework such as phpDocumentor. Supporting a simple documentation syntax, phpDocumentor will parse your source files and generate user-friendly documentation for you!
Another hindrance to understanding the intent of source code is poor formatting. Yet in the heat of banging out reams of new scripts, it can be easy to improperly indent and organize your code. You can automate this process using the PEAR package PHP_Beautifier, which among other tasks will properly indent your code and add newlines.
If you're considering embracing one or more of the aforementioned utilities, consider checking out the continuous integration tool known as phpUnderControl. Built atop CruiseControl, phpUnderControl packages several PHP tools together, including PHPUnit and phpDocumentor, to provide a unified interface for managing these features.
Do you have a favorite PHP-oriented productivity-enhancing utility not mentioned here? Tell us about it in the comments!