implementing ddd concepts in php
DESCRIPTION
A brief introduction to the concepts of domain driven design and their application to PHP.TRANSCRIPT
![Page 1: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/1.jpg)
Implementing DDD Concepts in PHP
Steve Rhoades
Panasonic Avionics
http://github.com/steverhoades@steverhoadeshttp://linkedin.com/in/steverhoadeshttp://stephenrhoades.com
Aleksey KhudyakovRoave, LLC
http://github.com/Xerkushttp://roave.com
Special Thanks
Marco Pivetta, Roave LLC http://github.com/ocramius
![Page 2: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/2.jpg)
Overview• Ubiquitous Language• Bounded Context• Value Object• Entity• Repository• Collection• Mapper• Identity Map• Unit of Work• Services
![Page 3: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/3.jpg)
What is Domain Driven Design
![Page 4: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/4.jpg)
Collection of principles and patterns that help developers craft elegant systems
![Page 5: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/5.jpg)
Ubiquitous Language
![Page 6: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/6.jpg)
Allows for precise communication of ideas between stakeholders and developers
![Page 7: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/7.jpg)
Developers should speak the language as well as include the language in the code base
![Page 8: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/8.jpg)
![Page 9: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/9.jpg)
Bounded Context
![Page 10: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/10.jpg)
Keep varying business processes separated
![Page 11: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/11.jpg)
Overlapping of business concerns should communicate through services
![Page 12: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/12.jpg)
Value Object
![Page 13: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/13.jpg)
An object that contains attributes but does not have an identity
![Page 14: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/14.jpg)
Value Objects are Immutable
![Page 15: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/15.jpg)
![Page 16: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/16.jpg)
Don’t forget behaviors!
![Page 17: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/17.jpg)
![Page 18: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/18.jpg)
Entity
![Page 19: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/19.jpg)
An entity is an object in your application that has an identity.
![Page 20: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/20.jpg)
Anemic Entity anti-pattern
![Page 21: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/21.jpg)
Look like Value Objects but have identity
![Page 22: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/22.jpg)
Lack behavior
![Page 23: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/23.jpg)
![Page 24: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/24.jpg)
![Page 25: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/25.jpg)
Repository
![Page 26: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/26.jpg)
A segregated interface that utilizes the ubiquitous language to hide the infrastructure layer
![Page 27: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/27.jpg)
Storage, Memory, Remote Service
![Page 28: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/28.jpg)
![Page 29: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/29.jpg)
![Page 30: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/30.jpg)
![Page 31: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/31.jpg)
Collections
![Page 32: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/32.jpg)
![Page 33: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/33.jpg)
![Page 34: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/34.jpg)
Mapper (Data Mapper)
![Page 35: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/35.jpg)
Used to pull Entity data from persistence
![Page 36: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/36.jpg)
Developers can create custom Data Mappers without affecting the rest of the application
![Page 37: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/37.jpg)
• Unit Test• MongoDB• Redis• MySQL• Oracle• Web Services• File System
![Page 38: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/38.jpg)
![Page 39: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/39.jpg)
![Page 40: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/40.jpg)
Identity Map
![Page 41: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/41.jpg)
Caches Entities in memory to ensure there is only one instance in memory at any given time
![Page 42: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/42.jpg)
Martin FowlerP of EAA
READ THIS!
![Page 43: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/43.jpg)
![Page 44: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/44.jpg)
Services
![Page 45: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/45.jpg)
Utilized when the natural processing on an Entity or a Value Object is no longer valid
![Page 46: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/46.jpg)
Domain Services should not contain state
![Page 47: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/47.jpg)
![Page 48: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/48.jpg)
Application Services and Domain Services are often confused
![Page 49: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/49.jpg)
Application Services orchestrate demands from a given use case or workflow
![Page 50: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/50.jpg)
Application Services “should not” contain business logic will make calls to Domain and Infrastructure services as well as Entities
![Page 51: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/51.jpg)
Helpful to think of an Application Service as a command object
![Page 52: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/52.jpg)
Unit of Work(example of Application Service)
![Page 53: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/53.jpg)
Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency
- Martin Fowler, P of EAA
![Page 54: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/54.jpg)
![Page 55: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/55.jpg)
Further Resources• Domain Driven Design, Eric Evans• Patterns of Enterprise Application Architecture,
Martin Fowler• Applying Domain-Driven Design and Patterns,
Jimmy Nilsson• Implementing Domain Driven Design, Vernon
Vaughn
![Page 56: Implementing DDD Concepts in PHP](https://reader030.vdocuments.site/reader030/viewer/2022020110/54814f4cb4af9f5c758b4689/html5/thumbnails/56.jpg)
Please Review
https://joind.in/9594