Review of "Zend Framework 2.0 by Example"

A few weeks ago I have been asked to review Zend Framework 2.0 by Example from Krishna Shasankar V. As of today, I have finished the book and here are my thoughts. In short: it is a mediocre book about the framework, but for beginners quite complete in it’s overview.

The step-by-step learning style in the book is excellent to learn the different parts. The sections “what just happened?” (a short review about the previous paragraphs), “have a go hero” (a short challenge to dive further into the framework) and “summary (at the end of every chapter) are a perfect idea for reflection and further investigation. However, I think the book has left quite some details unattended; the sections are not always in a logical order, the presentation can sometimes decrease the understanding of the topic and the quality of the code can be improved. Overall, it is a nice to have book for beginners. If you are already somewhat familiar with the framework, get your information from some other sources.

Contents

The outline of the book is pretty straightforward. The book has 193 pages of content, divided over ten chapters:

  1. Getting started: install Zend Server, mysql and create your database
  2. Building your first app: get the skeleton application and understand the framework’s structure
  3. Forms and databases: create a page to display a form, validate its input and store the data in a database
  4. Services and factories: learn to create services and how to share objects in your application
  5. Views, emails and events: work with view helpers to reuse view logic, send emails with Zend\Mail and use the event system to create custom hooks
  6. Media: work with image uploads, a 3rd party module to resize the images and the Google API to upload a photo to a Google Photos account
  7. Search: use Lucene to create a search index and use the index to query for items
  8. eCommerce: a step-by-step tutorial to create a small ecommerce application with PayPal Express Checkout
  9. HTML5: a listing of all the HTML5 view helpers and form elements
  10. Mobile applications: a short summary to build a mobile application with PhonegGap, Zend Framework 2 and a cloud service provider

The good

The book is a step-by-step guide which showcases the different parts of Zend Framework 2. In every chapter different components are loaded into the sample application called “Communication App”. This lets users experience with the different parts of the framework, including modules from a 3rd party. It happens a few times a module is loaded and this shows the typical power of module reuse in Zend Framework 2.

The language used is easy to follow for any reader with even a little understanding of English. The screenshots point you in the direction where the application is going. The typographical differences between normal text and code are also large enough to distinguish both types clearly.

I like that the level of explanation decreases over the chapters in the book. Half way past the book, there are little end-to-end code examples, but rather directives “create this type of object” and then “implement these methods which should do these things”. It helps to become independent from the guidance of the book and prepares readers to go along themselves.

There is a certain level of php knowledge required. I feel this is a good thing as Zend Framework 2 is certainly not meant for php laymen. It expects a level of object-oriented programming, php and perhaps even a little understanding of it’s predecessor, Zend Framework 2. As Krishna puts it:

Who is this book for?
If you are a PHP developer who is new to Zend Framework, but you want to get hands-on with the product quickly, this book is for you. Basic knowledge of object-oriented programming with PHP is expected.

A last thing I’d to mention is the " What just happened? " sections in every chapter. It is a certain reflection of a task performed just earlier on. Several readers might just follow the step-by-step guide with little understanding of what they do, but they can realize the effects with these short summaries.

The bad

There are, unfortunately, also quite some parts which I have a lot critique about. I can be very critical about details, which I think are all very important aspects of a book. Therefore I might judge the book differently than someone else, so you might disagree with me on the following:

Folder structures are explained via screenshots of a file manager. The low- contrast, low-resolution images are very inefficient to get a clear overview of all the files and folder. If you have a first hands-on experience with the framework, this isn’t the best method.

Furthermore, it is extremely important that new users understand the concepts of the module system. However, in this book, the MVC layer of the framework is mixed up with the module system. This doesn’t do good to both both components. After reading chapter 2, you probably still struggle with the module system and the MVC layer.

The configuration of variables (think: database credentials and so on) are separated in Zend Framework 2 between global and local variables. There is a big difference, because all global configuration is checked into your version control system and the local files are not. To be safe and secure, every password should be entered into the local files, so you can keep them safe in a password storage, outside your version control. However, in this book there is no explanation of the difference and the complete database config is put into a global file. I really don’t like this style and I strongly advice anyone to remove the database configuration into a local config file.

A last remark is the setup of a user authentication system. A user can log in, register him/herself or logout again. What is really worrying here is Krishna uses the md5() algorithm to hash the passwords. I mean, seriously, how can you advise md5 as a hashing technique in 2013? This is a big no-no for me and I can’t emphasize enough that you should not use md5 anymore!

The ugly

If you are really nitpicky, there is a tremendous amount of details which raise my eyebrows. First, the book is reviewed by three technical reviewers. None of them have any experience with Zend Framework 2, or at least, this is not mentioned in the biography. If you review a book about a new framework, you must have at least some experience, I guess?

Furthermore the level of English is sufficient to write a book, but Krishna juggles often with verb tenses and subjects. The “we” is often mixed with “you” and “I” which makes the text harder to read. Many sentences are formed in the present participle (verbs ending on -ing) which makes the text also hard to read. An example from the introduction of chapter 2:

In this chapter, we are going to create our first Zend Framework 2 project; we will be reviewing some of the key aspects of building a ZF2 MVC application by creating modules, controllers, and views. We will be creating our own custom modules in Zend Framework which will be enhanced further in subsequent chapters of this book.

There might be code examples which define a lot of variables where the explanation of the variables is scarce. This is typically true for chapter 3, where a database connection is made via Zend\Db. In a few lines, a TableGateway, database Adapter and ResultSet are used. How these objects are tied together is not explained well, as for example the description of the $adapter variable is " Used to provide the database adapter name “.

Final judgement

My conclusion is this book is a good resource to get some hands-on experience with Zend Framework 2 for people who never have used this framework before. It helps users to understand the different parts and principles of the framework and its ecosystem.

On the other hand, if you have a little project done with Zend Framework already, I suggest to look at other resources. The book is quite slim and covers all components briefly. For more in-depth knowledge of the framework, you can probably find other resources which are more helpful.

NB. This review has also been posted on Amazon.com.