DDD in PHP
Domain-Driven Design transported into the PHP realm: dynamic and interpreted language, short-lived objects...
»
Domain-Driven Design in PHP
It must be web
Not compiled, but interpreted
Not statically typed, but dynamic
Generic(s) code
JavaScript, CSS, HTML...
jsTestDriver, Selenium, PHPUnit...
Domain Model Objects are in memory
For 2 milliseconds...
Public website?
Scalability
Security
Private application!
Maintainability
Business understanding
What is an application server?
From Domain Model to View Model
Data over the wire: JSON
What is concurrency?
Optimistic Locking
One aggregate at a time
Events flow to lazy-loaded Repositories
No SQL queries in the wild
No Active Record
It's OOP
class Vehicle { ...
private $plate;
/**
* @var Operator
*/
private $operator;
class Dto_Leaf {
private $fields = array();
}
Domain Model objects are stored into a relational database
An ORM is needed... Doctrine 2
Implements large part of JPA
Fights with Value Objects...
/**
* @Entity
*/
class User {
/**
* @Column(type="datetime")
*/
private $registration_date;
1. Use @Entity
2. Custom column-field conversion rule
/**
* @Column(type="vat_rate")
*/
private $vat_rate;
3. Deconstruction with lifecycle hooks
/**
* @Column(type="integer")
*/
private $vat_rate_code;
/**
* @Column(type="integer")
*/
private $var_rate_percentage;
4. Serialization
/**
* @Column(type=object)
*/
private $vat_rate;
but
VatCode::calculateTax($imponibile)
new VatCode(...);
What has changed?
Programmer's mindset
ORM details
Where do you keep your objects
Metaprogramming
but they are still organized as Aggregates
but even when one of them is generic, the layers are the same
There can be Clean Coders in the PHP world
but you can still have Value Objects
Thanks
Browser
Presentation Layer
Service Layer
Domain Model
We started from this:
Giorgio Sironi
Bachelor in Computer Engineering
Former Architect, now Advisor @ Allbus
Zone Leader @ DZone
The language is different
The language
The platform
The Domain Model
No JSON in my domain
Ext JS, Zend Framework...
I learned this from Gojko Adzic articles
Giorgio SironiMore presentations by Giorgio Sironi
Popular presentations
Resultados de las Primarias 2012
Multimedia El Universal on
Resultados de las elecciones Primarias de la oposición venezolana para escoger candidato presidencial
30 Things About Me
Brooke Ahrens on
All About Brooke Ahrens- I used this presentation as an icebreaker to introduce myself to my classes this year.
Future-Proof Your Education
Maria Andersen on
How do you prepare for uncertain career paths where technical knowledge doubles every two years? You pay attention to the skills that surround the content: ...
More popular prezis in Explore>