Tuesday, March 02, 2010

Zend Framework 1.8 Web Application Development review

This is my personal review of Zend Framework 1.8 Web Application Development, a book by Keith Pope (affiliate link).

First, a clarification on the book's name, which refers to Zend Framework 1.8: the book work flow is based on the 1.8 version but the Api of Zend Framework is now stable, and thus even if now the latest release is 1.10, the book is not outdated at all. Zend Framework 1 would have been the wrong title as the 1.5 and 1.8 (which saw the introduction of Zend_Tool) releases were the real turning points.

After having read its 300+ pages, my general impression of this book is good. A problem often faced by frameworks is the relearning of php basic features: how to pass a parameter, add a page, generate an url, etc. which were very quickly solved by the author in the first chapters. This book starts from the ground up and adds the functionalities that cover 80% of the use cases, harnessing the power of Zend Framework. Zend Framework has a large Api, and knowing the right methods to call is fundamental.
The author does not skip panoramics of what happens under the hood of Zend Framework, which is very useful for debugging purposes and for deepen the understanding of other infrastructure such as the ajax requests helper (not included) and Zend_Test.
The whole point of the book is in developing a showcase Zend Framework application for an online store, complete with an electronic cart. As you know, I prefer hands-on approaches to programming and I think code is the best model for a software, way better than diagrams. I was happy to see that every version of the application (which progresses trough the different chapters) is present in the downloadable package.

Components treated
  • Zend_Controller and Zend_View (plus Zend_Layout) in the management of the Mvc machine.
  • Zend_Db for the implementation of model persistence resources.
  • Zend_Tool for the creation of an application from scratch.
  • extensive guide to Zend_Form, which is one of the most time-saving components and one of the most difficult to leverage because of its large Api and many functionalities. Decorators, filters and validators are widely used.
  • Zend_Session, in a quite elaborate example. I think I would have simply just put domain objects in a Zend_Session_Namespace.
  • Zend_Auth and Zend_Acl for authentication and authorization (management of identity and permissions).
  • Zend_Cache for optimization of different parts of the application. This is not micro-optimization, and the author highlights simple solutions like avoiding multiple actions dispatching and activating Apc over complicate practices.
  • Zend_Test for integration testing of the controllers.
Model
The sample application in this book implements a maybe overengineered database-agnostic model, which would thus be a good solution for decoupling and testing purposes. Though, ZF 1.x does not have the infrastructure to achieve a pure Domain Model without a great effort (currently work is being done on integrating Doctrine for simpler object-relational mapping.) As a result, the domain model has highly specific ResourceItem and Resource classes which sit in the middle between the Active Record and the Data Mapper patterns.
This model design is not "pure", but it gets the job done, maintaining the fat model and skinny controller paradigm. Though, I would not purport it as an example. Remember that the Model part of your Mvc application is up to you: the book is only about learning how to leverage Zend Framework, not about object-oriented programming. There is a great example of a model that does not use the database at all: if you are stuck with ActiveRecord, this way of thinking will open your mind.

If you want to dive into Zend Framework, this book will teach you a lesson on the most important components, saving you hours of digging the Api and the reference manual.

4 comments:

Anonymous said...

I would like to exchange links with your site www.blogger.com
Is this possible?

Mr. Weird said...

...

I don't get why all these reviews of this book is so positive.

The codes is fills with error. His CSS code is wrong so you don't see the logo of the website. His Bootstrap.php and main.phtml in layout is wrong because they're full links instead of relative link to the CSS. Not only that his code does not work after fixing every errors that aren't in the errata.

I got the website and stuff to show up, but his categories link only work with parent. Anything below it does not WORK. Click on Hat or Scarves and you get to an error page! I believe it's the router problem but since I am still learning I don't know where to start debugging the author's OWN code!

I've been scouring the web for some sort of helps on what the hell is going on but every single one of these reviews make it seems like these codes work.

What's worst is you can't debug the author codes when you're just learning the damn thing.

Giorgio said...

I have seen that most of these reviews (also mine) were written because Packt Publishing sent the book to Zend Framework experts for evaluation. Thus I believe there is a bias here - you see reviews which are written mostly from people that are already using Zend Framework proficiently, and as so probably may not notice the issues like a developer new to the field would.

Anonymous said...

To resolve the issues of ther hat and scarve pages not working, I went into the htaccess file and changed /index.php to the absolute file on my localhost being http://localhost/mysite/index.php. And also all links in the css files to images and also in bootsrap file I made absolute e.g in my boostrap file I had appendStylesheet('/css/main.css') changed to appendStylesheet('http://localhost/mysite/public/css/main.css'). Get the gist I think it as something to do with the authors localhost configuration being different. Hope that helps

ShareThis