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
@reinink: sure thing.
This would be the basic setup. Controllers are framework things, views would optionally reside here too. To me
events
are explicitly part of the domain. The domain emits and responds to them. This is one of the reasons I created league/events so you can have a domain focused lightweight events system. This also creates a nice separation between domain events and infra events, which both have valid reasons to exist. The same goes for commands, in symfony and laravel a "command" might be a console command, which is perfectly fine. However, in the domain it probably makes more sense to have commands as well but then let them be commandbus commands. Again, both are valid. I also try to steer clear from type suffixing in the domain. UserHasLoggedIn is a description of an event, thus event is implied. While theEvent
suffix might be a common thing to see it's all about "naming patterns". So, let's apply the type suffing to something else in our domain. If we have a User and a user needs to be verified before the user can log in we may keep track of that with a boolean. If we were to create a class to represent this boolean, would we name it ActivationBoolean? Probably not. Anywho, I like to think about those kind of things as well, all in the context of scoping/grouping/naming things.