New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement DDD Inspired Folder Structure #1839
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tn3rb
force-pushed
the
EDTR/folder-structure
branch
from
November 12, 2019 21:53
26f64fc
to
0297355
Compare
tn3rb
added this to Review in progress
in EDTR Conversion to Apollo GraphQL. branch: EDTR/master
Nov 12, 2019
nicolad
previously approved these changes
Nov 13, 2019
EDTR Conversion to Apollo GraphQL. branch: EDTR/master
automation
moved this from Review in progress
to Reviewer approved
Nov 13, 2019
manzoorwanijk
previously approved these changes
Nov 13, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! 👍
tn3rb
force-pushed
the
EDTR/folder-structure
branch
from
November 13, 2019 15:52
a62ad21
to
a7d8915
Compare
EDTR Conversion to Apollo GraphQL. branch: EDTR/master
automation
moved this from Reviewer approved
to Review in progress
Nov 13, 2019
tn3rb
force-pushed
the
EDTR/folder-structure
branch
from
November 13, 2019 16:00
a7d8915
to
aff35e0
Compare
nicolad
approved these changes
Nov 13, 2019
EDTR Conversion to Apollo GraphQL. branch: EDTR/master
automation
moved this from Review in progress
to Reviewer approved
Nov 13, 2019
EDTR Conversion to Apollo GraphQL. branch: EDTR/master
automation
moved this from Reviewer approved
to Done
Nov 13, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To keep things better organized I would like to follow a Domain Driven Design (DDD) / Onion Architecture inspired folder layout.
The primary layers are as follows:
infrastructure
application
domain
Here's the full structure:
PLZ NOTE: everything previously in the
src
folder has been moved into theZZZ
folderFurther Points to Consider
The most important thing to take away from the above structure is that the bulk of the logic should ultimately be grouped into specific "domains" also called "bounded contexts" in DDD. A "bounded context" essentially means a group of interrelated parts and/or processes with clearly defined edges. An example might be an "admin context" or "admin domain", which would be composed of everything related to the admin side of an application (domains can also be nested).
For the EDTR, I have added
/assets/src/domain/event-editor
as a starting point, but you will notice that there is also an/assets/src/application/controllers/event-editor
folder as well as an/assets/src/application/ui/web/event-editor
folder. I'm not sure yet whether we will want or need these. Ideally, the/assets/src/domain
folder is reserved just for core business logic that can then be accessed accordingly based on the current request type (api, cli, rss, web, etc)(i know some of these don't apply to our use case atm).The idea behind
/assets/src/application/controllers/
is for any logic required for routing requests to the appropriate domain and ui elements, the latter of which would be located in the corresponding/assets/src/application/ui
folder for the request type. It's possible that we won't require any kind of routing as that will be handled totally on the PHP side of things where the requests get handled initially.Some developers like to place all of their UI related logic in a separate presentation layer in the root of their applications to keep things separated even more like:
which we may want to do as well, depending on how crowded we expect things to get.
For the
infrastructure
layer I currently just have some generic folders for putting things in, but some devs like to also separate logic here based on the infrastructure type in a manner similar to the "bounded contexts" in the domain layer. So for example, you might have folders likeso we might also want to do something like this as well.
Last point I want to make is that the above proposed structure is not set and stone and may be different than other things you have seen regarding DDD (if you've even read about if before). Lots of DDD proponents organize things completely differently and there is little consensus about even how the various layers are stacked, for example, the application layer is often considered the outermost layer and the infrastructure layer can be the innermost or sometimes as a layer that runs perpendicular to the others. Ultimately it just has to make sense and work for us.