Namespaced Applications with Zend Framework 1.x
November 3, 2010
Whenever I would set up a new Zend Framework application, I would always worry about whether my directories were set up properly for ZF's module autoloader. The folder names don't match the model names: models are located in the 'models' directory but should be named 'Model_x' and controllers are in the 'controllers' directory and named 'xController'. On top of that, the default module is special because controllers don't have a namespace prefix like other modules would (IndexController vs. Module_IndexController).
The whole thing seems rather complicated with a bunch of special cases, which has always left me looking at the documentation to figure out which folder structure is correct (it also doesn't help that the ZF site has at least 3 different recommendations for folder structure). I would also imagine (although I haven't done any testing), all of these special cases would make the autoloader slightly slower than if it were doing a straight translation of class names to folder names.
My other issue with the resource autoloader is that it doesn't allow you to use PHP 5.3 namespaces. This is understandable as it's a rather new feature and Zend Framework 1.x isn't looking to drastically change (I look forward to how ZF 2 will change this). That being said, I happen to like namespaces and thought it would be great if I could use them in my ZF applications. So, ZendX_Application53 was born.
ZendX_Application53 is a set of classes that extend the Zend Framework to allow for namespacing your application classes, to simplify the autoloader, and to normalize the folder structure. The goal was to minimize the number of changes that you have to make to a base ZF application in order to get the new features.
The Github page has details on how to set up a new project as well as an example project so I won't go into too much detail on the actual setup. I've been using this framework for some personal and professional projects, but I cannot gurantee that all of the bases have been covered. One thing that cannot be namespaced currently is plugins.