Zend Framework - my three month review
Thursday, November 6th, 2008I have been using the Zend Framework almost daily for the past three months and my verdict on it is a mixed bag. I really, really wanted to like ZF three months ago when we chose to use it at work for our ongoing project and I do - with a few reservations.
I know my verdict is tainted by Ruby on Rails and CodeIgniter (I’m proficient in the use of both of them) but it’s always nice to have a reference point. I’ll get my reservations out of the way first.
What I don’t like
- Zend Framework Validation:
The Zend Framework has a very robust and flexible validation library. However the framework encourages validating data in the controller. In my view, validation is business logic and is thus a model function. Our current implementation actually moves the validation to the model (we added smarts to Zend_Db_Table_Row and implemented an ActiveRecord). - Zend Forms:
In the same vein, ZF encourages creating complete forms in the controller. A form is HTML and belongs in the view. Furthermore we have designers working with us and as such real forms are preferable. On my own personal projects though, I suppose creating my form (including validation) the Zend Way would actually speed up my work. The jury’s still out on that one, though. - Learning curve:
ZF is complex. After three months I still haven’t covered all the fundamentals and constantly have the manual open. I guess this means it’s got a lot of functionality but it also means I’m still a ZF beginner. - Verbosity:
ZF has a more verbose syntax than the other frameworks I’m used to.Compare the following view code:
Zend Framework: <?php echo $this->escape($this->name); ?>; Ruby on Rails: <%= h(@name) %>
And the following controller code:
Zend Framework: $data = $this->getRequest()->getPost('name'); CodeIgniter: $data = $this->input->post('name');
- Flexibility:
The Zend Framework is flexible (perhaps too flexible?). For everything that needs doing in ZF, there are at least three ways of doing it. This means it’s highly unlikely that two applications written with ZF will be similar unlike a rigid framework like Rails or CakePHP. Comparing the source for Magento Commerce and Digitalus CMS (two open source web apps built on the Zend Framework) proves this.
What I do like
-
Flexibility:
Yes, the flexibility is both a minus and a plus for me. ZF can be twisted to do practically anything you need it to do.
The classes can be easily extended and have loads of configurable options. With ZF, if you can think it, you really can do it. -
The Education:
Browsing the Zend Framework source code is a real education in best practice PHP programming and the use of design patterns in PHP. ZF is clearly written by folks who know their stuff and really highlights the best of PHP5 programming. -
Proper Decoupling:
The Zend Framework components honour the open/closed principle to the letter. The classes are so easy to extend and to reuse within and outside the framework. The ease with which modifications can be made actually encourage experimentation. A case in point is the ActiveRecord functionality we added to ZF. It’s a welcome change from all the intercoupling in CodeIgniter. I actually gave up trying to get CodeIgniter models to run isolated unit tests because the models needed an instance of the CI object to work. -
Zend Test:
ZF comes bundled with a built-in testing component based on PHPUnit (since version 1.6). Actually that was the clincher for me in the choice of framework as the Zend’s IDE (more on this below) comes bundled with PHPUnit testing support. The test component does have a couple of things lacking (in my opinion database support would have been nice) but it wasn’t hard to extend it to our liking. Also, I’m sure with later versions, this component will be improved. CakePHP does have a better-featured test framework based on simpletest but I do like the IDE support (with code coverage) in the ZF offering. -
Zend Studio:
Zend Studio rocks! Zend Studio has built-in support for the Zend Framework, PHPUnit testing, code coverage, debugging and loads of other goodies to speed up PHP work. If you code PHP for a living, you owe it to yourself to check this out. The support for ZF has also eased the learning curve considerably. I still fall back to Dreamweaver if I’ve got extensive CSS or HTML code to write but I’m slowly starting to use Zend Studio even for these although DW is still way better.
Would I use ZF for my own personal projects? It depends. I actually plan to use it for an application I will be realeasing next year but the motivation to use it is based on the modularity and the ease with which the framework can be extended and not development speed. For a more focused web app, I’ll still stick with CI.

