How to apply the Onion architecture with Symfony framework
|
Layer: Application Core (application + domain)
|
|
Layer: Presentation
|
|
Layer: Infrastructure
|
|
Layer: Tests
|
|
Domain
|
has no interaction direct with outerlayer. It represents the domain business and domain logic. It defines always the domain specific entities, value objects, events, exceptions, services, factories, interfaces.
|
|
Application
|
Application layer manages the internal domain logic. It provides different application services, which enable the communication with presentation, tests and infrastructure.
|
|
models
|
consist of entities, value objects, aggregates
|
|
repository interface
|
interfaces to access the business models, which are used by application and implemented by outer layer. For example: infrastructure
|
|
assertions
|
the business rules to adjust changes on business behavior and business models
|
|
services
|
domain services define the complex internal communication among the domain models. For example: apply some changes cross different domain models.
|
|
events
|
which can be used to track the state changes of domain
|
|
events / Event Subcriber
|
defines the events, which represent the state changes in business domain. for example:
|
|
services
|
theser services enable the interaction with internal domains by using the predefined interfaces in the domain layer.
|
|
query interface
|
These interfaces are defined for fetching the domain data. They are commonly used by presentation layer and implemented by infrastructure layer.
|
|
command
|
they are simple objects, which are used to change the state of business domain. For example: confirmPayment
|
|
controllers
|
controllers are the typical gateways for interaction comming from end user. It can be a controller, that represents REST endpoint; or a controller, that renders the web page.
|
|
consoles
|
It enables the user to access and update the application core via console in terminal.
|
|
templates
|
provide the template to define how to represent the business data. for example: template of email, template of exports, template of preview
|
|
views/forms
|
provide the UX interface to end users
|
|
DTO
|
Data Transfer Object, defines the view model of request and response
|
|
doctrine
|
query implementations
|
|
mail
|
repository implementations
|
|
filesystem
|
exports
|
|
Queue
|
cron-jobs
|
|
SSO
|
logging
|
|
unit tests
|
test if internal application core works well
|
|
integration
|
test if the communication between application core and external services in infrastructure layer is possible
|
|
functional
|
test if the interaction between end user and the presentation layer work well
|
Core
├── Application
│ ├── Command
│ ├── Event
│ ├── Query
│ └── Service
└── Domain
├── Event
├── Model
├── Repository(interfaces only)
├── Service
└── Validation
Presentation
├── Api
│ └── Rest
│ ├── Controller
│ └── DTO
│ └── SOAP
│ ├── Controller
│ └── DTO
├── Console
│ └── Command
│ └── DTO
└── Web
├── Backoffice
│ ├── Asset
│ ├── Controller
│ ├── DTO
│ ├── Form
│ └── Twig
└── Portal
├── Asset
├── Controller
├── DTO
├── Form
└── Twig
Infrastructure
├── Mail
├── Persistence
│ └── Doctrine
│ ├── Migrations
│ └── Repository
├── Queue
└── SSO
Tests
├── functional
├── integration
└── unit
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.