Grouped modules by name or by type???

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Grouped modules by name or by type???

Post by alex.barylski »

Assume you have a application compoed of several pages, each page consists of several components or entities (language files, images, templates, etc)

Do you store those files grouped by module/page name

Code: Select all

aboutus/
 - aboutus.tpl
 - aboutus.gif
 - aboutus.ini
 - aboutus.lng
Or do you organize the files into directories which reflect their purpose:

Code: Select all

langs/
 - aboutus.lng
 - someother.lng

templates/
 - aboutus.tpl
 - someother.tpl
Personally I go with the latter, although I am considering going with the former which would allow easy automation using convention - although I dislike the idea of implicitness it is nice once you work with it for a while.

Likely a subjective choice, but i'm curious why you would choose one over the other, naming both advantages/disadvantages would be ideal :)
User avatar
xinnex
Forum Commoner
Posts: 33
Joined: Sun Jan 07, 2007 7:38 pm
Location: Copenhagen, Denmark

Post by xinnex »

Excellent question, and very similar to the ones I've been asking recently.

So far, this seems like the best solution for me (subject to changes of course):

Code: Select all

application/
- aboutus/
-- controllers/
-- templates/
-- lang/

- gallery/
-- controllers/
-- templates/
-- models/
-- lang/
As you can see a module like about us or gallery is a "full package" with everything needed for this specific module.
The only thing really needed by the existing system (through a frontcontroller-pattern) is the controllers in each module.

To put it short, I store files by module and then purpose.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Types for me.

Code: Select all

/www
-/lib
-/app
-/views
Xoligy
Forum Commoner
Posts: 53
Joined: Sun Mar 04, 2007 5:35 am

Post by Xoligy »

The latter for me. I find it easier since using the former means you're going off the extension when clicking which isn't as obvious to me.
Post Reply