About this chapter
Strategic design gave you the map: a ubiquitous language and bounded contexts. This chapter zooms in on the code. These are the tactical patterns - the building blocks you use to turn a domain model into classes that are hard to misuse. You'll learn the difference between an entity (identity that survives change) and a value object (immutable, compared by value), how an aggregate groups objects behind a single root that guards the rules, how domain events record what happened, and how repositories, domain services and factories keep the model clean. Every lesson has a short PHP 8.4 example you can adapt.
Lessons from courses
- 1 Entities: identity that survives change Learn what an entity is in Domain-Driven Design: an object with identity that persists through change. Identity vs equality, with a PHP 8.4 example.
- 2 Value objects: immutable, compared by value Learn what a value object is in Domain-Driven Design: immutable, self-validating, compared by value, with a PHP 8.4 readonly example.
- 3 Aggregates and the aggregate root Learn what an aggregate and aggregate root are in Domain-Driven Design: one consistency boundary, one entry point that enforces invariants. PHP example.
- 4 Domain events: recording what happened Learn what a domain event is in Domain-Driven Design: a past-tense record of what happened, raised by aggregates to decouple side effects. PHP example.
- 5 Repositories: a collection of aggregates Learn the repository pattern in Domain-Driven Design: a collection-like interface that stores and retrieves aggregates, hiding the database. PHP example.
- 6 Domain services and factories Learn domain services for logic that fits no single entity, and factories that build complex aggregates in a valid state. Clear PHP 8.4 examples in DDD.