PHP and the Zend Framework

I’ve recently decided to become one of the ‘architecture astronauts‘ and give the Zend Framework a go within my new PHP applications. My major hesitations with using any PHP framework usually revolve around the usual suspects, including code bloat, learning curve, and unecessary complexity. The majority of my PHP projects are fairly simplistic and are developed by a very small group of developers so they dont take full advantage of code seperation, templating, OOP, and whatever soup de jour is being offered.

So why have I sold out? Primarily this will be a learning experience that will allow me to develop my object oriented skills a little further. I’m also thinking of starting up a larger open source project with the community and would like to be able to confidently recommend the best possible core architecture – be it a framework, custom code library, or other ad-hoc solution.

Meet the Zend Framework

The Zend Framework pushes the concept of standardizing PHP code, and attempts to harvest the best practises learned and used by professional developers into a simple, reusable framework. All code is complete with a corporate friendly license and has been reviewed by the community at large.

Some of the more popular components include:

  • Zend_Acl: Provides Access Control List (ACL) functionality and privileges management
  • Zend_Config: Simplifies the use of configuration data for Web applications
  • Zend_Controller and Zend_View: Provides the infrastructure for Model-View_Controller (MVC) Websites
  • Zend_Feed: Provides a simple way to work with live syndicated feeds
  • Zend_Filter and Zend_Validate: Facilitates the development of secure Websites by providing basic tools necessary for filtering and validation
  • Zend_Gdata: Google data APIs that provide read/write access to services hosted at google.com such as Spreadsheets, Calendar, Blogger, and CodeSearch
  • Zend_Mail and Zend_Mime: Create and send email messages
  • Zend_PDF: Creates, reads, and modifies PDF documents from PHP applications

Other interesting features and abilities are:

  • AJAX support through JSON – meet the ease-of-use requirements your users have come to expect
  • Search – a native PHP edition of the industry-standard Lucene search engine
  • Syndication – the data formats & easy access to them your Web 2.0 applications need
  • Web Services – Zend Framework aims to be the premier place to consume & publish web services
  • High-quality, object-oriented PHP 5 class library – attention to best practices like design patterns, unit testing, & loose coupling

The Zend Framework can be downloaded for free from http://framework.zend.com/

Getting started is made a little easier by the fact that you, the developer, have a choice of which components you choose to use. Typically, I will copy the /library/Zend folder into my application/library folder, and reference it direclty this way. In the future I will probably choose to copy the Zend folder to a shared location – perhaps /var/share/Zend on my webserver and have all my projects reference this folder directly instead of copying a version of ZF for each project seperately.

The programmer’s reference Guide can be found at http://framework.zend.com/manual/en. It’s usually easiest to keep the manual open in a seperate window and refer to it as you’re writing your application. The document itself is of fairly decent quality (better than MSDN?) and has quite a few helpful examples for each component.

For the sake of brevity I will leave you to play with the framework on your own for now. Feel free to comment / email me your thoughts and experiences and I’ll be sure to incorporate them into future ZF posts.

Cheers!

One Response to “PHP and the Zend Framework”

  1. Paul G. says:

    Hey Aaron,

    This is a cool high level overview of the Zend Framework. I have decided to try it myself.

    Some other interesting PHP frameworks exist out there as well. I recently came across a job opportunity that required the applicant to know ’symfony’ http://www.symfony-project.org I have never tried it but am curious about… maybe time permitting I will.

    Personally I have tried QCodo: http://qcodo.com but found it to be limitating (in some ways) and very useful in other ways especially if you have a MySQL relational database on the backend. QCodo will automatically generate PHP pages to select, insert, update & delete records. It’s also very easy to set up and use.

    Anyway it would be awesome to see some more info on Zend working with MySQL. On the Zend site, they have a simple application example using SQLite… but for beginners / newbs with limited time it can be hard to translate to MySQL (as far as connectivity, etc.)

Leave a Reply