Application Directory (Folders) Structure

My goal was to create a structure that is very easy to understand, flexible enough for big or small websites and not totally different from what books or other guides recommend as a best practice files and folders structure for a Zend Framework project.

Another goal was to create a core cms, which has lots of modules that can be used on multiple websites. Every module is designed so that it can be copied and put in another cms without having to modify any file of that cms. The module of a directory holds all the files it need to work, i has its own bootstrap, its configuration files, its views and of course its own models.

This post contains the recommended structure for an application developed using the Zend Framework (ZF) based on the quick start, but there are several changes made by me. I won't use the controllers folder, i will put my default controllers in the homepage module directory which is my default module. As you can see the MVC strucure is in the modules directory...

The models directory has several sub folders, for mongo db models, for mysql (maria db) models, for session management models and another one for the xml read / write models.

The views folders in each module directory contain the view scripts for the actions and there is a helpers folders for module specific helpers. The helpers that can be used website wide are put in the helpers folder that is in the layout directory.

Every module also has a configs folder for module configuration files, like the config.xml, the translations.tmx file, the routes.xml file, the acl rules and resources xml file and eventually some other xml files containing the widgets layouts. There is also a main configs folder in the application directory where i store files which have values that can be used website wide by all modules.

Create the following application folders structure:

myapp
|-- application
| |-- caches
| |-- configs
| |-- layouts
| | |-- helpers
| | `-- scripts
| |-- logs
| |-- modules
| | |-- admin
| | | |-- configs
| | | |-- controllers
| | | |-- forms
| | | |-- models
| | | | |-- mongo
| | | | |-- mysql
| | | | |-- session
| | | | `-- xml
| | | `-- views
| | | |-- helpers
| | | `-- scripts
| | |-- homepage
| | `-- news
| |-- services
| `-- widgets
|-- library
| |-- My
| `-- Zend
`-- public
|-- captcha
|-- css
|-- fonts
|-- images
|-- javascript
|-- qrcodes
`-- uploads

* myapp is the main directory
* the application folder will contain everything related to your app (your php code), we put all our code one level lower then the public files so that they aren't publicly-accessible
* the public folder will contain files like your css, javascript and images (you can also rename this folder htaccess)
* the library folder is for your library and the zend library

Download the latest version of the Zend Framework and put it into the "library" folder.

This is how myapp directory is build, there are more layouts you could try. More Informations about Zend Framework folder layouts can be found here: http://framework.zend.com/wiki/display/ZFDEV/Choosing+Your+Application's+Directory+Layout

Ok now your ready for the next step, creating the index.php file ... to be continued ;)

原文地址:http://www.chris.lu/en/news/show/4d40a471d6186/

 

你可能感兴趣的:(Application Directory (Folders) Structure)