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
Credits
Foreword
About the Authors
Acknowledgments
www.PacktPub.com
Customer Feedback
Dedication
Preface
14
Bibliography
15
The End

Requests


We need to send the email and password to the Application Service. There are many ways of doing such a thing from the client (HTML form, API client, or even the command line). We could just send standard parameters (email and password) through the method signature or build and send a data structure with this information. The latter approach, sending a DTO, brings some interesting features to the table. By sending an object, it'll be possible to serialize and queue it over a Command Bus. It'll also be possible to add type safety and some IDE help, too.

Note

Data Transfer Object A DTO is a data structure that carries information between processes. Don't mistake it for a full-featured object. A DTO doesn't have any behavior except for storage and retrieval of its own data (accessors and mutators). DTOs are simple objects that shouldn't contain any business logic that would require testing.

As Vaughn Vernon says:

Application Service method signatures use only primitive types (int, strings...