Hexagonal Architecture + DDD + CQRS in PHP using Symfony 7
Hexagonal Architecture + DDD + CQRS in PHP using Symfony 7
Example of a PHP application using Domain-Driven Design (DDD) and Command Query Responsibility Segregation
(CQRS) principles keeping the code as simple as possible.
Take a look, play and have fun with this.
Stars are welcome
View Demo
·
Report a bug
·
Request a feature
git clone https://github.com/CodelyTV/php-ddd-example php-ddd-examplecd php-ddd-examplecp .env .env.local) if you want to modify any parametermake buildmake depsmake testThis project tries to be a MOOC (Massive Open Online Course) platform. It's decoupled from any framework, but it has some Symfony and Laravel implementations.
This repository follows the Hexagonal Architecture pattern. Also, it's structured using modules.
With this, we can see that the current structure of a Bounded Context is:
…Our repositories try to be as simple as possible usually only containing 2 methods search and save.
If we need some query with more filters we use the Specification pattern also known as Criteria pattern. So we add a
searchByCriteria method.
You can see an example here and its implementation here.
You can see an example of an aggregate here. All aggregates should extend the AggregateRoot.
There is 1 implementations of the command bus.
The Query Bus uses the Symfony Message Bus.
The Event Bus uses the Symfony Message Bus. The MySql Bus uses a MySql+Pulling as a bus. The RabbitMQ Bus uses RabbitMQ C extension.
Every time a domain event is published it's exported to Prometheus. You can access to the Prometheus panel here.
There are some things missing (add swagger, improve documentation...), feel free to add this if you want! If you want some guidelines feel free to contact us :)
This code was shown in the From framework coupled code to #microservices through #DDD talk and doubts where answered in the DDD y CQRS: Preguntas Frecuentes video.
Used in the CodelyTV Pro courses:
No open issues yet, or sync has not completed.