Skip to content

Instantly share code, notes, and snippets.

@reinink
Created April 11, 2016 10:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save reinink/504a9654c4348dbc0dc81ff4313fb588 to your computer and use it in GitHub Desktop.
Save reinink/504a9654c4348dbc0dc81ff4313fb588 to your computer and use it in GitHub Desktop.
How do you typically organize your classes?

By type

  • /Controllers
  • /Events
  • /Models

By topic

  • /Comments
  • /Posts
  • /Users

By topic, then type

  • /Comments
    • /Controllers
    • /Events
    • /Models
  • /Posts
    • /Controllers
    • /Events
    • /Models
  • /Users
    • /Controllers
    • /Events
    • /Models

Mixed

  • /Comments
  • /Controllers
  • /Events
  • /Models
  • /Posts
  • /Users
@aminemat
Copy link

By topic (sub-domain), entities in the sub-domain root folder, then by type
example with 2 topics, Shifts and Employees:

structure

@frankdejonge
Copy link

@shochdoerfer I'm still toying with the 1 dir 2 dirs X dirs setup. One thing I don't like is to have to group the domain in an arbitrary namespace. I often see the Web/Http namespacing, but then it comes with a "Domain" namespace too which pretty much always puts me off.

@stefanbauer
Copy link

Even this is a really, really old gist, I'd still just wanted to share my thoughts on it, which I wrote a blog post about it: https://stefanbauer.me/articles/an-alternative-way-to-organize-the-laravel-directory-structure - I think it's basically what @frankdejonge is doing. Do it for several years now and still happy with it – at least if we're talking about larger projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment