Event sourcing using Laravel
Who am I?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/760725/images/5426980/19029742_10212118839960433_3809399219961601328_n.jpg)
Damiano Petrungaro
Italy
![](https://s3.amazonaws.com/media-p.slid.es/uploads/760725/images/6150916/italy.jpg)
source: www.vidiani.com
Tivoli (RM)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/760725/images/6150921/tivoli.jpg)
source: www.livitaly.com
Tivoli (RM)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/760725/images/6154240/buche-villanova-3.jpg)
source: www.romaest.org
Tivoli (RM)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/760725/images/6154243/arco.jpg)
source: www.tivolitouring.com
Tivoli (RM)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/760725/images/6154245/traffico.jpg)
source: www.confinelive.it
Tivoli (RM)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/760725/images/6154257/greenpark.jpg)
source: www.greenparkmadama.it
Me everyday:
![](https://s3.amazonaws.com/media-p.slid.es/uploads/760725/images/6222124/me-chicken.jpeg)
Event sourcing
Capture all changes to an application state as a sequence of events.
CQRS
It's a pattern that I first heard described by Greg Young.
At its heart is the notion that you can use a different model to update information than the model you use to read information.
command query responsibility segregation
Command
vs
Query
Events
It's an immutable object used to represent something important that occurred in the domain.
Events
let's code
Domain model
It's a mutable object with an identity, it can be represented in different ways.
It's comparable to other entities by its ID.
Aggregate root
A DDD aggregate is a cluster of domain objects that can be treated as a single unit.
An example may be an order and its line-items, these will be separate objects, but it's useful to treat the order (together with its line items) as a single aggregate.
aka: write model
Value Object
It's an immutable object representing a value in a domain.
It's comparable to other value objects by its own values.
Domain Model
let's code
Command
It's a write operation!
Command
let's code
Extra: Repository
It's an abstraction layer to provide access to all the entities and the value objects related to an aggregate.
Extra: Repository
let's code
Read Model
A read model is a model specialized for reads, that is, queries.
It takes events produced by the domain and uses them to build and maintain a model that is suitable for answering the client's queries.
It can draw on events from different aggregates and even different types of aggregate.
Projection
Projection is a specialized representation of the state derivated from of our system
Read Model
&
Projector
let's code
Discussions & Questions
101
Let's do some homework
Copy of Event sourcing using Laravel
By Nastasi Christian
Copy of Event sourcing using Laravel
- 136