Replies: 1 comment 1 reply
-
We use something like suggested structure in https://github.com/yiisoft/demo/tree/master/src |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm looking at the docs on directory structure and I notice that you seem to be going for a structure that's largely based on the type of the content that will go into the folders. For example
resources/layout
andresources/view
andsrc/Controller
andsrc/Command
.This is nothing new of course. In fact, most frameworks seem to do this. I've been seeing folder structures like this for 20 years now. Also often seen are
public/scripts
,public/images
etc.So familiar stuff... But best? I'd say no. Not even close.
If I build a new module for some app, say one that deals with uploads, and for that module I need some public assets (icons etc). some controllers, a command etc etc, I end up having to add folders all over the project. Wouldn't it be much nicer if we could have a folder structure based on modules? Where I place all the files related to a module in subfolders of a
src/modules
folder? To get a feel for what I mean have a look at this Stack Overflow question that asks about changing from one type of structure to the other and has some nice illustrative screenshots.Have you guys given this any thought? I've always felt that the structure based on types is very inconvenient and I've also seen that people are never consistent about it. If you check what's inside
public/images
for example, sometimes they will have say 'icons' and 'backgrounds' folders in it (consistent), but mostly either directly underimages
or otherwise underimages/icons
andimages/backgrounds
people will almost always switch to a module-based structure. They end up with something like this:Now if they would be consistent, they would have
...etc, continuing to split up based on the type of content. But people hardly ever do this. I almost always see the switch to module based approach. I reckon they do that because it just becomes ever more unwieldy as you keep doing this. Your code for one module will en up spread out over many different folders.
So why do so many frameworks give us a type-based structure out of the box?
I dare say it's out of convenience for the framework devs and because that's just how it's done in many other frameworks. I understand it's easier to serve all static files from
public
, expect all controllers undersrc/Controller
etc. But again, best for the application / library developer? I say no.So my question is have you given this much thought and would you consider going a different route here?
Beta Was this translation helpful? Give feedback.
All reactions