development (in)action

Starting a Zend Framework Project [1/2]

Recently I have been asked to introduce and assist with starting Zend Framework projects; over time I have learned through trial, error and banging my head against a wall a few tricks, shortcuts and nuances. In this series I will take the life cycle of a Zend Framework project from beginning to never-end and cover each portion as completely as I can and provide a place for discussion to improve my process or detail it further. It should be clear the intent of this article is not to discuss development methodology or any process outside of the scope of using Zend Framework itself.

A project is born.

Beginning with a name for the project established (for the purpose of this write-up I have decided on ZendDB) we should begin by creating the project reference within Eclipse, Zend Studio or your preferred editors method. Before we begin any code creation or development we need to insure we have the required tools on our system to begin.

Following this we must establish where we will edit, build and work on the project and initialize the project contents using the zf tool, create additional directories for build and validation.
The build related files and directories tie all components into a collective suite of tools, utilizing ant or phing we will be able to execute all reports as one single command. This practice also lays the foundation for continuous integration, which this project will evolve into as time goes on. To enable each of these tools we will use we must create their associated configurations, begin by editing build.phpcs.xml
I have intentionally kept this example simple and to the point, I strongly recommend you visit the PHP_CodeSniffer project for more details on its capabilities. Once complete the PHPUnit configuration is setup with the various types of reports it should generate, the test suites it will cover.
For more details on PHPUnits report capabilities and xml configuration options visit the PHPUnit Documentation. Now this is established we may bring it all together with the ant build.xml file. This file will allow us to create/remove required build artifacts, report directories and execute phpunit, phpcs and phpdoc all in a single stack.
For a more detailed overview of an ant build file please see Apache Ant; it should also be noted that Phing is a php alternative to ant and should be interoperable with ant. To utilize the build script you need only execute ant within the top-level directory of the project, the example file provided will create phpdocs, code sniff the project and execute all unit tests. Reports will be stored within build/* for review.

In the next edition to this I will cover database configuration and model creation.