Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

There are a million-and-one file-system structures that go into the myriad of Open Source projects available. Things like modules, language files, domains, third-party libraries, migrations, internationalization, backups, and syslinks to other parts of the system have given rise to many approaches to organize the filesystem of a project.

As a PHP developer I'm wondering if any type of standardization is starting to emerge among projects. With PSR-0 we finally have a standard for naming and loading files - but it nothing to my knowledge about the rest of the components that make up the system or how they can be handled in a sane way.

We are dealing with a lot more than just MVC, so what examples are there of large projects correctly handling all of these things?

share|improve this question
3  
As a fellow PHP developer, I wouldn't expect sanity from PHP components –  CamelBlues Aug 29 '11 at 19:41
2  
@CamelBlues Based on the pure odds of chance, some PHP developer has got to mess-up eventually and do something right. –  Xeoncross Aug 29 '11 at 21:44
    
I haven't seen much as far as standardization. Until the last few years you would have your folders for front-end things (js, css) and then you would have includes or libs and then templates or themes and that was it. Recently with the MVC frameworks gaining popularity it is all unclear. I would say not to worry about using a standard for now and just keep it clear what goes where in your particular application. –  Jason Dec 30 '11 at 21:07

3 Answers 3

up vote 2 down vote accepted

It isn't really possible to standardise how projects should be laid out, because "it depends".

If you introduce a standard structure, but some of it isn't relevant to the requirements being developed, you can end up with additional noise that you don't need. Similarly, if the standards need to work for a wide range of projects, they will need to incorporate too many disparate scenarios.

Our job as developers is to look for patterns and best practices and apply them to the task in hand. We use our experience and expertise to choose the right file system structure for the project we are working on.

share|improve this answer
    
+1 As a whole I agree with you, this is certainly a valid point. However, if you remove things outside the language (backup folders, cron/build scripts, static assets, etc..) and just focus on the language itself - I don't believe the same argument can be made. Languages already have limitations imposed. Figuring out how to arrange all your classes and codeblocks so they make sense for every project is a real and attainable goal. –  Xeoncross Mar 12 '12 at 16:13

There doesn't seem to be much of a standardization effort going on, and to be honest, I don't see the benefit. There is only one rule you should adhere to, which is that you should never have things under the docroot that don't belong there (a basic security precaution).

Other than that, I'd just go with what makes sense for the project.

If you're using MVC (either through a framework or ad-hoc), then a base structure with /models, /views and /controllers makes sense. But even if you're not, you usually have some sort of data access layer with classes that map to your data entities; it makes sense to have a directory for those; you also usually have a bunch of business logic classes and utility functions, so another directory for those; if you use a template system, templates go into another directory; and then you probably want a 'libraries' directory, where you put all third-party libraries. (Once you've reached this point, you're pretty much doing MVC anyway).

If the project is really large, it can probably divided into functional submodules; if the submodules are fairly independent, it makes sense to use those as your top-level instead, with one additional directory for the common code.

share|improve this answer

You can follow the project layout for the two most popular application frameworks:

  1. Zend Framework - http://www.framework.zend.com/manual/en/project-structure.project.html
  2. Symfony - http://symfony.com/doc/current/book/installation.html

These will provide an extensible structure based on best practices and experiences from users

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.