Zend Framework modular directory structure
by Gabi SolomonAfter a lot of thinking and going back and forth about this idea, i finally decided to start using ( learning at first ) zend framework.
The main decision was to go with an already built framework or an inhouse one. And although i really like reinventing the wheel sometimes, i said i will not do the same this time.
After deciding i wanted to use an exiting framework, i had 2 candidates in mind : CodeIgniter or zend framework. The plus for codeigniter was the fact that it went with a more familiar approach to MVC, and the plus for zend was the company behind it. The downside about zend, was for me at least, the size of it, and the fact that it seemed a lot to learn.
But i decided to take a chance and learn Zend. The main problem i had was how to start ( as all things are
). Because the have such a freedom in development, i was a little puzzled on how to structure my application.
The only thing i knew was that i wanted to go with a modular structure. From there i did a lot of googling, read and watched a few presentation about this topic and finaly came up with a structure wich is bassed much on Wil Sinclair proposal.
My Zend modular structure
I will try to explain it, why i chose it this way and what each folder contains.

1. Application
The main aplication folder
1.1 Config – Contains application configuration files ( ex: mysql details )
1.2 Controllers – General Controllers, that are common in all modules
1.3 Languages – Holds the language files
1.4 Layouts – This directory is for MCV based layouts.
1.5 Models – This directory holds the application models ( in put them here instead of the modules directory since i belive there are common to all application and its more better this way )
1.6 Modules – I really liked the idea of modules that zend used because it enables you to organize your controllers and views much better in a separate folder for different sections of a website ( for example the main website, editors area and admin panel )
1.7 Views – I also included a views folder in the main application because i though i could use it to store common views for the 3 modules.
2. Data
This folder holds various information that is temporary, like cache, session data etc.
3. Docs
This directory is for documentation automatically generated or hand written.
4. Library
This directory holds the library Zend Framework files and also other folders for your own library (extended from Zend or not). I have one called GSD that extends some zend classes.
5. Public
This directory would contain the public files for your application: index.php. index.php ( this will include the bootstrap.php file from your application/ directory) and the front end assets (css, javascript, images, flash etc )
6. Tests
This directory would hold the application tests. This is a cool feature about Zend that it has support for writing application tests to better test your code during development.
Final Words
Ok this is about it so far. I am still a beginer with zend, and this structure is what i have thought off so far, and it doesn’t have some real application testing. Use it at your own expense
)
I am sure as i start developing using zend that it will be modified.
Another bad thing about zend is that there aren’t so much resources and real examples about it, this is why i will write about my journey with zend here. Hopefully somebody will benefit from it.
Cheers
Related Posts
-
modular homes
-
Gabi Solomon
-
olga
-
Gabi Solomon
-
Djaarf
-
Gabi Solomon
-
The Willer
-
Directory

