Zend Framework 1.8 Web Application Development - Book Review
Title: Zend Framework 1.8 Web Application Development
Author: Keith Pope
Publisher: Packt Publishing Ltd
ISBN 13 978-1-847194-22-0
The Zend Framework community needed a book covering version 1.8+. Version 1.8 brought new notable features. Zend_Application is one among them. Zend_Application introduced object oriented bootstrapping in applications that otherwise used a procedural script. A bunch of users had difficulty understanding how to set up their applications to make use of the new bootstrapping component. All of them have seem to understand it well now, thanks to support in the official mailing lists and IRC channel. Zend_Navigation, Zend_Tool and enhancements to filter and validation components were other noteworthy additions to Zend Framework 1.8. For a full list of changes and additions to the 1.8 version see the release notes.
I contacted PackT Publishing Ltd and asked for the book to write this review. They were kind enough to quickly send me a copy of the ebook.
Let's begin exploring the book.
Chapter 1 gently introduces MVC concepts and explains setting up your first Zend Framework based application. The author initiates a discussion on project directory structure, bootstrapping, controller and views.
Chapter 2 kicks off MVC discussion to the next level. The building blocks of the Zend Framework MVC components are thoroughly explained. If you are reading the book, read this chapter carefully. A good understanding of the following components will help you make the most of Zend Framework MVC :
- Front Controller
- Request Object
- Response Object
If you are new to MVC it might be difficult to grasp all the theory and Zend Framework implementation perfectly in one go. I myself have read the controller section of the Zend Framework official reference guide several times to get a firm grip on the subject. If you are like me, reading this chapter again helps immensely.
The author has chosen to build a store front to demonstrate design, development and deployment of the application. Throughout the book, the Zend Framework components are explained in conjunction to the sample application. Chapter 3 explains the basic settings of the store front. Zend_Application is presented well. Zend_Layout, Zend_Db, Zend_Debug and Zend_Logger are the other components introduced to the reader. If not already, Zend Framework users eventually choose to use a coding standard. I appreciate the fact that the author has written about coding standards.
Beginners are often surprised that there is no Zend Framework model class. The M in MVC is intentionally not developed allowing the user to implement the model layer as per their project requirement. Chapter 4 is dedicated to the design and development of the model layer of store front application. I must warn the seasoned developer, this is not a book on implementation of patterns from the Patterns of Enterprise Application Architecture and Domain-Driven Design: Tackling Complexity in the Heart of Software books. That doesn't mean the model implementation of the sample application is mediocre. In fact the chapter is quite interesting. Do you think a book on Zend Framework should teach the best practices of model design?
The store front application has an obvious catalog feature. Chapter 5 walks you through the model, controller and view layers associated to the catalog. Zend_Db_Table with Zend_Db_Table_Row and relationships is explained in this chapter. The Action Stack Plugin is used to populate a block in the template. Many Zend Framework users do not recommend this type of Action Stack usage. View helpers and routes are among other things discussed in this chapter.
Chapter 6 delves into implementation of user accounts. After a thorough explanation of user model, Zend_Form is described. The Zend Framework community knows the fact that many beginners are baffled by Zend_Form decorators. The author clearly explains how Zend_Form uses decorators to generate the mark up. Writing custom validators is also demonstrated.
Chapter 7 details the shopping cart implementation.
Chapter 8 details Zend_Auth and Zend_Acl. Although, Zend_Auth and Zend_Acl components seem to be straightforward, I have seen some beginners struggling with them. The access control and authentication implementation in the book is definitely not the best I have seen so far. The point I would like to stress here is, learn how the Zend_Auth and Zend_Acl components work. There's no obligation to copy the sample application's authentication and authorization implementation in your applications.
Chapter 9 walks you through the steps of creating the administration area of the application. Writing a front controller plugin, action helper and custom routes are some of the things you will learn in this chapter.
Chapter 10 delves into the discussion of modules. Bootstrapping modules and inter operation between different modules are discussed.
Chapter 11 discusses some of the optimization techniques you can use to boost performance. Alas, Zend_Cache is introduced. The rest of the information presented seem to reiterate the performance section of the reference guide.
Chapter 12 introduces unit testing. The chapter is not an exhaustive tutorial of unit testing and PHPUnit. But it sure gets you started with Zend_Test. Read the documentation of PHPUnit, if you are not familiar with it already. Girgio and Jani have written good tutorials about unit testing.
What are the good parts of the book?
- Explanation of MVC concepts and the related Zend Framework components
- Zend_Form and decorators
- Reasoning behind each major design decision of the store front application
- Chapter on testing
What could have been done better?
- Throughout the book I could spot spelling mistakes. This is not a major issue, per se. But the publishers should review it for the next edition and reprint.
- In some examples, the author uses URLs like 127.0.0.1:8080. The usage of port 8080 could have been avoided for brevity.
- Being a book on web development the example URIs should use the domain example.com instead of domain.com. Call me pedantic. I personally, get irritated by such domain name usage, especially in a book.
- In chapter 6, the author could have chosen to use Zend_Validate_Db_NoRecordExists instead of the custom validator. Nevertheless, it serves the purpose of teaching how to write a custom validator. Things like these and the fact that the preface mentions, "As of this writing, the current version is 1.5.3 and the core components are at a mature stable state" indicates the author started writing the book when the Zend Framework version was at 1.5.3 and later rushed to cover version 1.8.
- The book does not cover some of the other important components of the Zend Framework. There are a whole bunch of web services and third party API consumer classes in the Zend Framework. Coverage of either Zend_Dojo or ZendX_Jquery would have been nice. It is surprising the author did not choose to include i18n and l10n components. Chapter 5 could have demonstrated the usage Zend_Navigation. Wouldn't you expect the book to cover the mentioned topics?
The goal of the book is to teach you Zend Framework. Once you understand how Zend Framework works, you decide how to use it in your applications. You don't necessarily have to dub the store front application design in all your projects. Don't be upset if the book doesn't use a particular object like you would prefer to. If you are not familiar with object oriented programming, I strongly recommend you to learn it prior to reading this book. The book assumes you are familiar with inheritance, interfaces and other usual concepts anyone would expect from a PHP developer having experience in object oriented programming. PHP in Action: Objects, Design, Agility is a good book to learn advanced programming in PHP. In any case, the book is not going to be a one stop shop for all things Zend Framework. There are other resources you can use to learn more about Zend Framework.
- The official mailing lists
- The official reference guide
- IRC channel - #zftalk on freenode.net
- Pádraic Brady has published a free book on Zend Framework
- Matthew's blog
- Akrabat's blog
Rating: 4 out of 5.