DDD with Symfony

Posted on by

Problem
Many Symfony applications gradually become tightly coupled, making business logic hard to test, evolve, and reuse as infrastructure concerns leak into the domain.

Stack
PHP 8.4, Symfony 7, Doctrine ORM, PostgreSQL, PHPUnit, Docker

Key decision
Organized the application around Domain-Driven Design and Clean Architecture instead of Symfony bundles or technical layers. Business rules live exclusively in the Domain, with the Application layer orchestrating use cases through ports, while Infrastructure contains only technical implementations. This keeps the domain framework-agnostic and independently testable.

Metrics tracked
Unit test coverage of the domain, architecture rule compliance, dependency direction (Infrastructure → Application → Domain), and use case execution through command/query handlers.

Result
A production-ready Symfony template demonstrating how to build maintainable, testable applications with DDD, CQRS, and Hexagonal Architecture, serving as a reference implementation for real-world business systems.