Book Image

Domain-Driven Design in PHP

By : Keyvan Akbary, Carlos Buenosvinos, Christian Soronellas
Book Image

Domain-Driven Design in PHP

By: Keyvan Akbary, Carlos Buenosvinos, Christian Soronellas

Overview of this book

Domain-Driven Design (DDD) has arrived in the PHP community, but for all the talk, there is very little real code. Without being in a training session and with no PHP real examples, learning DDD can be challenging. This book changes all that. It details how to implement tactical DDD patterns and gives full examples of topics such as integrating Bounded Contexts with REST, and DDD messaging strategies. In this book, the authors show you, with tons of details and examples, how to properly design Entities, Value Objects, Services, Domain Events, Aggregates, Factories, Repositories, Services, and Application Services with PHP. They show how to apply Hexagonal Architecture within your application whether you use an open source framework or your own.
Table of Contents (24 chapters)
Title Page
About the Authors
Customer Feedback
The End

Layered Architecture

From the code maintainability and reuse perspectives, the best way to make this code a bit easier to maintain would be by splitting up concepts, that is creating layers for each different concern. In our previous example, it's easy to shape different layers: one to encapsulate the data access and manipulation, another one to handle infrastructure concerns, and a final one for encapsulating the orchestration of the previous two. An essential rule of Layered Architecture — is that each layer must be tightly coupled with the layers beneath it, as shown in the following picture:

Layered Architecture for SoC

What Layered Architecture really seeks is the separation of the different components of an application. For instance, in terms of the previous example, a blog post representation must be completely independent of a blog post as a conceptual entity. A blog post as a conceptual entity can instead be associated with one or more representations, as opposed to being tightly...