Zend Framework Structure
On large open source builds, we use Zend Framework. The Zend Framework is a Model View Controller (MVC) Framework. The idea of this is to separate out the application logic from the user interface, allowing independent development, and maintenance of each step.
As part of this, we start all sites with a basic folder structure based around incorporating Zend; kind of like a framework around a framework.
We’ve worked on several projects in a particular way, but for our most recent project (a redevelopment of competwition.com) we started from scratch. We got a brand new shiny version of the framework (version 1.11), and sat down to properly plan out how we wanted the new framework to be built, and allow for it to expand in the future.
One of the main issues we came up with was how to structure the site around having a frontend and a backend (admin system), which may in some ways share a lot of data with the front end. For example; if you’re running a site with many products, your frontend will have the ability to query the database for the product information and display it, and so will your backend.
Models ‘model’ the data in an application – they do the database interaction too. This means that their logic should probably be shared between the two.
Our sites usually have a different admin area layout to help our users interact with the data they’re managing. This means that the layout and view ‘logic’ can be separate for the frontend and backend. In some systems, it might be best to keep these in the same place – if you’re allowing in-line editing for example.
The actual operation/controller ‘logic’ is also separate between the frontend and backend of the system. This is due to the different roles the two sides of the system allow for – the frontend will be mainly for viewing products (in our e-commerce example), whereas the backend will have the ability to add, edit, delete and view the products. Logically, it makes sense to keep these interaction sets separate, but as mentioned previously, the model logic can be shared between them.
At the end of the brainstorming session we came up with the following structure:
/ application/ admin/ controllers/ helpers/ layouts/ filters/ helpers/ scripts/ includes/ views/ filters/ helpers/ scripts/ configs/ forms/ public/ controllers/ helpers/ layouts/ filters/ helpers/ scripts/ includes/ views/ filters/ helpers/ scripts/ Bootstrap.php docs/ library/ public/ css/ js/ images/ uploads/ .htaccess index.php
Latest from B3Labs
- Another milestone reached for Branded3 as it’s acquired by the
St Ives Group
- The latest media consumer findings & what they mean for digital marketers
- Talk to Branded3 at @BuyYorkshire in Leeds next week!
Latest from Blogstorm
- After five years, Google still doesn’t know how to rank images
- Tickets now on sale for the next #B3Seminar in London – book now!
- Google Only Shows One Organic Result To iPad Users