Zend Framework 2 Released
Last week version 2 of the popular and powerful Zend Framework was released for production projects. The new version includes a module system aimed at adding “flexibility, simplicity, and re-usability” to the PHP framework.
“We’ve completely rewritten Zend Framework to simplify the process of architecting for different workflows,” said Matthew Weier O’Phinney who is the Zend Framework Project Leader and a popular PHP and web development blogger. “Now enterprises can seamlessly re-use functionality between different applications and sites using ZF2′s modular building blocks. We’ve also added important new security features. Lastly, and most importantly, our community continues to build and improve on ZF2, making what is already the most enterprise-capable PHP framework on the market even better.”
Modules in Zend Framework 2
O’Phinney has actually been discussing ZF2 modules on his blog for several months, indicating that module support was going to be a centerpiece in this latest release.
The goal of this new approach, according to O’Phinney, was “fairly simple, modules should be re-usable. Developers should be able to drop in third-party modules easily, and immediately utilize them with zero or small amounts of configuration. Developers should never have to directly alter module code, ever, to get them to work in their applications; customization should be easily achieved via configuration or substitution.”
In execution, this means that ZF2 modules may contain just about anything from MVC functions to images.
A new module autoloader locates and loads module classes. A module manager “takes an array of module names and fires a sequence of events for each one, allowing the behavior of the module system to be defined entirely by the listeners which are attached to the module manager.”
A new events manager plays a role in setting up the aforementioned listeners and allows developers “to attach and detach listeners to named events, both on a per-instance basis as well as via shared collections; trigger events; and interrupt execution of listeners,” according to the official ZF2 documentation.
Modules in ZF2 have a lot of promise, but using them is going to take some getting used to. Developers that have been using Zend Framework will still have a bit of learning to do, and developers that were just getting started may feel like this approach to modules adds a bit of complexity.
To help developers make the transition, a new getting started guide has been published in conjunction with the stable release of ZF2.
This guide and the ZF2 documentation more generally makes use of the Zend Skeleton Application available on Github to get developers familiar with the new architecture.
The Zend Community
Interested developers, who might generally be referred to as the Zend Community, have also added many comments to the ZF2 documentation, explaining potential problems and providing feedback.
This sort of community involvement is one of the best things about the Zend Framework, regardless of version. Zend developers are simply not alone; there are thousands of other code writers sharing the same experiences. This community involvement helped to define the new module feature mentioned above — O’Phinney said explicitly in his blog that users requested module support — and it will certainly help developers learn how to implement ZF2 modules.