Spiga

Zend Framework modular directory structure

December 01, 08 by Gabi Solomon

After 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 :D ). 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

Zend Studio FTP manager problem – dont see files

July 02, 08 by Gabi Solomon

Today i wanted to start work on a new project, so i open my Zend Studio Editor and add the FTP details for the new project in the File System ( feature that i love in Zend Studio :D ). But to my surprise something was not completely right.

The FTP seem to be added correctly, upon clicking connect it seem to connect just right, the color would turn to black from the unconnected gray, but the files and folders on the FTP would not show up. I spent one hour trying a bunch of stuff out. I tried reading the FTP Server, closing and reopening Zend Studio, even tried to restart windows as a disparate act. Nothing worked.

I tried googling the problem but no results came about this problem.

After some little thinking i tried adding exception to the windows firewall, with no luck, even disabled it but the same situation. Tried to do the same with the NOD antivirus system. Nothing seem to do the trick.

Before you comment if the FTP details were correct, they are … i tested them in a FTP client and it worked.

Finally just a few minutes ago i found the solution ! :D
The problem was that when i added the FTP Server at Initial Directory: i usualy left the default value of /, and the Editor would usually find the correct value which would be the account username on most cases. But for some reason on this FTP Server it didn’t do that so it tried to access the servers root folder where i didnt have any rights …. so no files to show.

I am glad i manage to fix this, and not use the E-TextEditor ( the FTP Server worked in it ) which although is a pretty nice editor with a lot of cool features, does not rock my boat. I got used to the Zend Studio interface and it would very hard for me to change to something else now.

Hope you find this article useful and find it when you encountered the same problem and maybe save some time.

Cheers