Domain-Driven Design in PHP
Domain-Driven Design in PHP
Summary:
Introduction
The book "Domain-Driven Design in PHP" (authors: Carlos Buenosvinos, Christian Soronellas, Keyvan Akbary, 2017, 400 pages) is not just another PHP guide, but a deep dive into the methodology of domain-driven design (DDD) as applied to web development in PHP. Unlike the classic books by Eric Evans or Vaughn Vernon, which describe DDD in abstract terms, this work offers concrete, ready-to-use patterns and code examples in PHP. It is aimed at developers who are already familiar with the basics of PHP and want to move to the next level—creating complex, maintainable, and scalable business applications.
What is this book about?
The book systematically covers all key DDD concepts: from basic building blocks (Entity, Value Object, Aggregate, Repository, Domain Service) to advanced techniques such as CQRS (Command Query Responsibility Segregation) and Event Sourcing. Each chapter contains not only theoretical explanations but also practical examples in PHP that can be immediately applied in real projects. Special attention is given to code organization, working with Doctrine ORM, integration with Symfony and Laravel, and testing domain logic.
Main topics of the book:
- DDD Building Blocks: Entity, Value Object, Aggregate, Repository, Factory, Domain Event.
- Domain Modeling: how to identify Bounded Contexts and build a Ubiquitous Language.
- Infrastructure: implementing repositories with Doctrine, working with transactions, Unit of Work.
- Advanced Patterns: CQRS, Event Sourcing, Application Services, Domain Services.
- Testing: unit testing of domain objects, integration testing of repositories, testing commands and events.
- Framework Integration: examples for Symfony and Laravel, setting up Dependency Injection, configuration.
Who is this book for?
The book will be useful for:
- Mid-level and senior PHP developers who want to master DDD and apply it in their projects.
- Architects and team leads who design complex business systems and are looking for ways to combat the "Big Ball of Mud."
- Developers transitioning from procedural or MVC styles to more meaningful domain modeling.
- Anyone who has already read Evans or Vaughn but wants to see how these ideas are implemented in PHP using modern tools (Composer, Doctrine, Symfony).
What will the reader learn?
After reading the book, the reader will be able to:
- Clearly distinguish between Entity and Value Object and understand when to use each.
- Design aggregates with correct consistency boundaries.
- Implement repositories that hide data storage details.
- Apply Domain Events for loose coupling between modules.
- Implement CQRS to separate commands and queries, simplifying scaling.
- Use Event Sourcing for complete state change auditing.
- Write tests that verify business rules, not infrastructure.
- Integrate the DDD approach with popular PHP frameworks.
Strengths of the book
The main advantage of the book is its practical focus. The authors do not just retell theory but show exactly how to write code. All examples are relevant for modern PHP versions (7.x), using Composer autoloading, type hints, traits, and other language features. The book contains numerous code listings that can be copied and adapted for your own project. Special mention should be made of the chapters on CQRS and Event Sourcing—they are written so accessibly that even a beginner in these topics will be able to understand them.
Recommendations
Deep Reinforcement Learning: Theory and Practice in Python
Design Patterns in Swift (iOS/macOS)
Testing C++ Applications: From Unit Tests to Integration Testing
Kotlin and Docker: Application Containerization
Functional Reactive Programming
Professional Android. Application Development for Professionals