Zend Framework Review PDF Print E-mail
Written by Joshua D Miller   
Friday, 01 May 2009 14:21

Introduction

Recently, I began exploring the most recent versions of the some popular PHP frameworks to see which one I liked best. In a previous post, I discussed the merits of using a PHP framework and some common features. There are several solid PHP application development frameworks

According to the Zend website:

Zend Framework is an open source, object oriented web application framework for PHP 5. ZF is often called a 'component library', because it has many loosely coupled components that you can use more or less independently. But Zend Framework also provides an advanced Model-View-Controller (MVC) implementation that can be used to establish a basic structure for your ZF applications.


Zend Framework indeed has all the major benefits one would expect from a mature php framework, such as:
  • Good Design Patterns, such as the MVC and Front Controller patterns
  • Object-Relational Mapping
  • Helps speed of development
  • PHP wrappers for implementing Web 2.0 functionality without writing any Javascript
  • Templating, providing for the separation of design and development tasks.
Zend Framework is clearly suitable for large- and small-scale projects; as such, the following sections discuss what stood out to me as what I liked and did not like about using Zend Framework.

What I Liked

Installation.

As Zend is a free-standing component library, the only "installation" necessary was taking the steps typical for setting up any project with a LAMP stack: set up a virtual host in Apache, get the latest version of PHP, etc. The new command-line interface (CLI), while leaving much to be desired (see next section), made project creation a breeze; by entering a couple of commands to the CLI, the script generated a basic bootstrapping framework, established the model-view-controller (MVC) pattern through logical (and completely configurable) file system directories, and created an .htaccess file for URL rewriting (creating search-engine- and human-friendly URLs).

Flexibility & Extensibility.

Zend framework is more-or-less a 'component library', as each component in the framework has minimal dependencies on the other components. This is one of my favorite aspects of the framework because, while the Zend Framework provides a very good and solid structure from which to build an application, the architecture allows the developer to selectively choose which components of the Framework he wishes to employ. Further, this 'loosely-coupled component' structure provides the added flexibility for seamlessly integrating third-party or proprietary libraries to supplement or replace many aspects of the Framework.


A great example: I was playing around using a data model for which I already did significant work with Doctrine 1.1 (http://www.doctrine-project.org), so I decided to test Zend's "use-at-will" design by modifying the Quick Start's Guestbook example to use Doctrine in place of the Zend_Db component. While I have written a separate blog on this, suffice it to say the integration was seamless - I modified less than 10 lines of code in the controller and added the usual 10-15 lines of code required to bootstrap Doctrine in any project. Very cool.

Quick Start Guide.

The Zend Framework Quick Start provides a solid introduction to developing applications with Zend Framework. The Quick Start walks the user through the creation of a simple guestbook application, including the use of several common components, such as Zend_Db for ORM, Zend_Form for form management and display, and Zend_Application for bootstrapping. This guide, while concise, presents the theory and application of thee common components in a simple example.

Bootstrapping Method

The new Zend_Application component and its autoloading and bootstrapping framework is sweet. While it has some limitations, it makes creating extensible applications with single configurations very easy. For a little more information, see another of my blog posts on Integrating Doctrine with Zend Framework .

What I Didn't Like


Reference Guide

Apart from the Quick Start and the API documentation, the Reference guide is the only available explanatory composition for Zend Framework. The Reference Guide is basically component-by-component documentation and while the Reference Guide is technically informative and contains solid background and theory, it is missing the "big picture". How components inter-relate is missing nearly entirely and there are not strong examples of the components in the context of an application. Some sections are significantly better than others, which I hope indicates the Reference Guide is more a work in progress rather than a final product.

Zend_Db


While Zend_Db seems to be somewhat of a work in progress, it has most of the features one would expect from an ORM suite. However, from my experience it is too close to the database. One of the benefits of Doctrine or Propel (the two leading PHP ORM frameworks) is complete abstraction from the database architecture in all aspects of object-relational mapping, and Zend_Db has a couple of minor shortfalls. In addition, both Doctrine and Propel have command-line utilities for the generation of model classes based on YAML or XML schemas or based on an existing database.

As it turns out, the shortcomings of Zend_Db are okay, as Zend Framework integrates so easily with third-party libraries, including Doctrine and Propel.

Compared to Symfony

One could argue that Symfony is the most worthy competing project of Zend Framework. As such, this section highlights some of the key differences (and similarities) between the two PHP frameworks. Overall, I noted that the two frameworks have remarkable similar potential in terms of usage; what you may find reading the following is that the differences between the two frameworks is largely stylistic.

Configuration

In Symfony, nearly all configuration is entered in YAML files by default. By contrast, ZF handles much configuration in PHP code with the occasional INI file. While both frameworks support all of these options, the "out-of-the-box" or "default" configurations are different.

There has been many a forum debate about the merits of each approach, so I will not take a position here; however, I will say that in the context of Zend Framework, I found the PHP with INI approach created an intuitive and seamless configuration, especially in the context of the integration of third-party libraries.

Documentation

In terms of documentation, Symfony wins outright. It's beginner documentation is significantly more in-depth and consistently focuses on the "big picture", rather than an isolated picture of each component. Symfony has three book-length manuals (one published by Apress, two by Lulu, but all available in HTML and PDF for free) covering all aspects of the Symfony framework. This is in addition to the API documentation and miscellaneous offered tutorials. While the Zend Framework Quick Start guide is very good, I found the Reference Guide left much to be desired.

Installation / Implementation

In terms of installation, the two frameworks remain quick simple: create the file structure, copy/link the libraries, and run a few commands through the CLI. However, Symfony is a complete package more than a component library. This has advantages and disadvantages. Principal among the advantages is that it is easier to get set up with multi-tiered applications. As just one example, rather than its own ORM implementation, both Doctrine and Propel are built in to Symfony and are accessible through the Symfony command line, making rapid application development very easy. However, off-setting this advantage is that it is more difficult to integrate third-party components and Symfony does not appear to have as sophisticated a bootstrapping and autoloading framework.

Design Patterns & Conventions

Both frameworks make heavy use of the Model-View-Controller (MVC) and Front Controller patterns and are very similar in default implementation. Both have a public folder with an index.php front controller and separate directories for back controllers, view scripts, and models. The proposed directory structures for each framework, while customizable, are by default very similar.

Command-Line Interface (CLI)

Symfony's CLI is much more advanced, but the Zend Framework CLI is new in 1.7.8 that came out early this month. Both support project setup and basic code generation, but Symfony has a more advanced feature-set and comes built-in with integrated support for Doctrine and Propel. Symfony's CLI also supports an easy back-end generator that creates controllers, forms, and (albeit boring) view scripts for administration areas of web applications. I expect Zend Framework will catch up in this area soon.

All in All

In recapitulation, Zend Framework has a lot of great features, is easy to integrate with third-party components, and is intuitive to implement. If your web application project running on a LAMP stack is available I recommend looking into Zend Framework as a potential application development suite.

Further Information / Sources


Zend Framework: http://framework.zend.com
Reference Guide: http://framework.zend.com/manual/en/
Quick Start Guide: http://framework.zend.com/docs/quickstart
Symfony Project: http://www.symfony-project.org/

Practical Symfony (Doctrine): http://www.symfony-project.org/jobeet/1_2/Doctrine/en/
Practical Symfony (Propel): http://www.symfony-project.org/jobeet/1_2/Propel/en/
Eclipse and PDT: http://www.eclipse.org/pdt/

For those curious, I tested the Zend Framework on a box with the following software:
  • Web Server: Apache 2.2.10
  • PHP: PHP 5.2.9
  • Database: MySQL 5.0.67
  • IDE: Eclipse 3.4.1 with PDT 2.0
  • Zend Framework: 1.7.8
  • Operating System: OpenSuSE Linux 11.1


Last Updated ( Wednesday, 20 May 2009 15:22 )
 

Open Source Projects Josh Supports :

   
Fedora Project   openSuSE Linux!   Ubutnu - Linux for Humans  Spread Firefox Affiliate