Zend Framework 2.0.0rc1, First Impressions

Zend Framework 2.0.0rc1 was released today. Unfortunately, I haven’t had time to keep up with ZF2 development since the early betas, so I had a read through Rob Allen’s ZF2 tutorial to see what has changed.

One interesting thing I saw was that the new Zend\Db\TableGateway uses the prototype pattern to instantiate result sets. Ralph Schindler explains the benefits of this approach in his blog post about constructors. TL;DR — using dynamic class instantiation (as was done in ZF1) is limiting because you have to make assumptions about the class’ constructor and dependencies. Using prototypes still allows you to choose the class used for result sets, but also provides flexibility around the class’ constructor and preserves any injected dependencies and configuration.

I also like how the new ServiceManager can use anonymous methods as factories, saving me from having to create dozens of tiny factory classes. And while I haven’t fully dug into the ViewModel stuff, from the little bits and pieces I’ve picked up from Twitter and coworkers it sounds like an elegant solution to the problem of passing context to the view renderer.

Put these improvements together with some of the stuff that has been there since the early betas such as events, improved routing, and better module support, and I’m really looking forward to using ZF2!

Zend Framework 2 Beta 2 Released, APC 3.1.9 for Lucid

I wasn’t very productive over the holidays (I blame Valkyria Chronicles), but it’s the new year, and that means new posts!

I’ve been playing around with Zend Framework 2, both at work and at home. As I mentioned in my presentation at SF PHP, it’s not ready for production yet, but each beta release includes a few more refactored components. I’ve been trying to play with each component as it’s released so I have a good understanding of how all the components work and how they might fit together in an app. I hope to blog some examples and best practices in the coming weeks.

Zend Framework 2.0.0 beta 2 was released in late December. It included a refactored Zend\Cache component, which requires APC >= 3.1.6. Unfortunately, I’m running Ubuntu 10.04 LTS (Lucid), which ships with APC 3.1.3p1. I was tempted to just spin up a new Precise Pangolin AMI, and I will probably end up doing that eventually because ZF2 requires PHP >= 5.3.3 and Lucid ships with PHP 5.3.2. But for the short term, the ZF2 MVC components seem to run on PHP 5.3.2, so I just compiled the latest version of APC, 3.1.9, for Lucid. The backported package is available on my PPA if you’re interested. Hopefully I can hold out until April when Ubuntu 12.04 LTS (Precise) is released.