/blog / series/ddd-hexagonal-symfony
DDD, CQRS and Hexagonal Architecture in Symfony 8
6 posts, in reading order
Domain-Driven Design and Hexagonal Architecture as they behave in a real Symfony 8 codebase: which component does what, what goes in which YAML file, and where the framework helps versus where it quietly pulls the design apart. The running example is a money-lending domain, built one block at a time.
Each part adds one layer to the same application — the domain model and the dependency rule, the application layer and a working HTTP API, CQRS read models, domain events on an asynchronous Messenger transport, then event sourcing swapped in behind the same port. Every recommendation comes with its cost, and the final part is the bill, measured from the example repository: what all of it buys, and the thresholds below which it is over-engineering.
$ posts in reading order
01
The Domain Model, and the Only Rule That Matters
DDD domain model in PHP 8.5 and Symfony 8: keep the container out of the domain, and choose Doctrine ORM or DBAL with the costs on the table. Series part 1.
▸ DDD, CQRS and Hexagonal Architecture in Symfony 8 · 1#ddd#hexagonal-architecture#symfony#php#doctrine#software-architecture15 min
02
The Application Layer, the Transaction, and a Working API
Application layer in Symfony 8: use cases on a Messenger command bus, the transaction boundary in config, optimistic locking and RFC 9457 errors. Part 2.
▸ DDD, CQRS and Hexagonal Architecture in Symfony 8 · 2#ddd#hexagonal-architecture#symfony#php#cqrs#messenger#software-architecture18 min
03
The Read Side Does Not Go Through the AggregateNEW
CQRS read models in Symfony 8: a read port the domain does not own, a query bus that returns a value, and when a projection table earns its place. Part 3.
▸ DDD, CQRS and Hexagonal Architecture in Symfony 8 · 3#cqrs#ddd#hexagonal-architecture#symfony#php#postgresql#doctrine15 min
04
Domain Events Are Not Integration EventsNEW
Domain events vs integration events in Symfony 8: recorded by the aggregate, released after commit, versioned into a contract, consumed by a worker. Part 4.
▸ DDD, CQRS and Hexagonal Architecture in Symfony 8 · 4#ddd#hexagonal-architecture#symfony#php#messenger#rabbitmq#domain-events19 min
05
Event Sourcing Behind the Port You Already HaveNEW
Event sourcing in Symfony 8: an event-sourced repository swapped in by one DI alias, proven by the same contract test, and what the alias did not cover. Part 5.
▸ DDD, CQRS and Hexagonal Architecture in Symfony 8 · 5#ddd#hexagonal-architecture#symfony#php#event-sourcing#postgresql#cqrs17 min
06
What This Architecture Cost, Measured Rather Than ArguedNEW
What hexagonal architecture costs in Symfony 8: ports, layers and buses counted from the repository, and the thresholds below which it is not worth it. Part 6.
▸ DDD, CQRS and Hexagonal Architecture in Symfony 8 · 6#ddd#hexagonal-architecture#symfony#php#software-architecture#cqrs#refactoring19 min