When I speak of scripting languages I am speaking of languages like Python, Perl, and (in my case) PHP. After using CodeIgniter, Zend, and lots of other fun MVC systems it seems clear that one thing one one seems to agree on is the folder structure (alongWithOTher things_like_that). This is really causing a problem for me because I can't find any good documentation on the benefits of different structure designs. Most people just recommend one because that is what they use without regard for improvements in design.
One of the things I hope we can all agree on is that checking the file system for existing files when autoloading classes is very bad practice. Our classes should not be in one of 5 possible locations causing a barrage of file_exists() checks for each library we load.
So anyway, I am trying to collect directory structures that I can compare to find the best practices when planning for applications that:
- Are OOP based which most likely means MVC
- Are International in scope and support language files/translations
- Are open to modules/plugins so that complete packages can be dropped into our codebase
- Clearly define what is going on and where to look for given classes
- Possible support for multiple sites running off the same structure (see /site directories below)
So here is what I have so far. Keep in mind that libs is just a term meaning your main library/class directory and may even contain models depending on the folder structure. Also, I excluded any type of static content (JS/CSS/images) as that stuff is really an after thought and not related to our serverside code - it may even be on another server! The same thing with caches, file uploads, lang, and all other generated content.
/controllers
/views
/models
/libs
/config
index.php
This kind of reminds me of the Zend framework which piles everything into a single libs folder (which also includes subfolders to keep things organized). Only works for a single site.
/libs
/site
/controllers
/views
/models
/config
index.php
This would a multi-site version of the above structure.
/libs
/functions
/site
/controllers
/models
/views
/config
/site2
/controllers
/models
/views
/config
/modules
/user
/controllers
/models
/views
index.php
This would be version that would allow multiple sites and drop in modules. The modules would be self contained MVC apps like a forum which would include business logic, CRUD, and views.
So does anyone have a perfect structure they could share or guide me in choosing a good extend-able design?