Default Dirs
31st May 2006There's an interesting thread on the ZF mailing list called Default Dirs which deals with where to put your code. It's well worth a read.
I've touched on this before, but thought I'd update my half a dozen readers on my current thinking :)
The manual suggests:
/application /models /views /controllers /document_root /images /styles .htaccess index.php /library /Zend
My current directory stucture currently looks like:
/application /models /views /controllers /schemas /tests config.ini /scripts /www /img /css /js .htaccess index.php /lib /Zend /Akrabat
As you can see I'm basically still following the manual, but have tweaked. I have used www rather than document_root because I have a scripts directory and want to emphasise that the stuff in www is for the web server and not for cli. I'm reasonably sure that anyone who has ZF experience could work out what's going on anyway.
Also, you might have noticed that I store config.ini in /app; It seemed like the logical place as there's only ever going to be one of them. I've also got a tests directory and a schemas directory. Schemas is for some work in progress stuff based on the ideas in Ruby on Rails's Migrations system. I'll write about it when I get a chance to actually make it all work!
An interesting question came up about the admin pages of an application. There are two alternatives:
- "within the site"
- "separate look and feel"
To be clear, in either case, you would use authentication to determine what the user has access to, but the way you present it is different.
In the first case, the "news/add" action would display a form within the look and feel of the website. i.e. the user doesn't change context, but just gets some extra menu options and features. In the second case, the user logs into a section of the site that looks completely different and has it's own menu system and features. Think about the admin you get for WordPress when writing a post and compare to the main site as an example.
I will probably do both types depending on the site. For community sites, I like to use the admin within the site feel as it makes it much easier for community members to take on roles like forum moderation. For corporate sites, I prefer a separate admin because the designs that customers like are useless for administration!
To implement, I am going to look at using a separate directory for the admin controllers and views as I think it will make it quicker to find the file that I'm looking for when I'm mainting it 2 years later.
Thus, I think something like this will work:
/app
/models
/views
/admin
/controllers
/admin
/schemas
/tests
config.ini
/scripts
/www
/img
/admin
/css
/admin
/js
/admin
.htaccess
index.php
/lib
/Zend
/Akrabat
I'll let you know if it works :)
