Hands on ZF2

The post is also available in: Swedish

Is about to set up a development environment for a project I have thought of for a long time now. My eyes have fallen on Zend Framework 2, which at this moment is in beta 3. I summarize in this post my views of the framework after a first glance.

Initial components of choice

I have started of by downloading ZendSkeletonApplication to be able to quickly get started. The frustration with code in beta can otherwise be a bit unbearable without a working example. Following an earlier crush I had on Doctrine made me decided to also set up their modules, DoctrineORMModule and DoctrineModule.

This is a good start to an initial position for a platform I want to work in. In addition, I also wanna have support for Assetic which is a framework in php for the project’s assets, ie css, js, images, etc.. Assetic helps to minify and manage assets and provides support to several aids such as LESS and Twig.
The main reason that I want to use this in my platform is the support it gives to local resources in the modules. Without such a management system we would have to work with symlinks or copy-paste for public assets.
It is worth mentioning that there is a module created for this purpose called zf2-assetic-module. I had some problems installing this though. I got a server error that I couldn’t solve. A problem that is left to further experiments in the future I guess.

Worth mentioning is a website where you can look for modules to your ZF application: http://modules.zendframework.com/

On that page there is among others a module, ZfcUser, that handles users. The module is also available with a Doctrine adapter. However, I would like to create my own user module in the beginning because I think it is instructive and a good first step in order to familiarize myself with how things work. I will probably later switch to using ZfcUser since it’s maintained by ZF-Commons.

To create my User module I started with ZendSkeletonModule and simply made the name changes where needed.


The framework is, as stated, in the beta stage and some flaws are to be reckoned with. When I looked around in the source code I notice above all the absence of proper documentation. Would like to see some better explanations how you can work with the tools that are offered directly in the IDE, or/and a link to a online documentation. I also detect syntax errors, some classes that inherit from there abstract parents without covering the abstract methods or declaring itself as abstract.

The overall impression is positive though. The architecture seems very thought out and well applied. Most appealing, I think, is the new modular structure which is central to the architecture. I think in ZF1 this was pretty fuzzy designed leading to many problems when it came to trying to preserve a good pattern.
How a module is built is specified in a module class which gives us a highly flexible base to work in. In the application configfil we can specify, in a very visual and logical manner, what order the modules is to be loaded.



One Comment

  1. So I am not the only one with configuration problems of the Assetic Module.

    Did you get it to work in the end?

Comments are closed.