litecqrs-php | Small convention based CQRS library for PHP | Microservice library
kandi X-RAY | litecqrs-php Summary
kandi X-RAY | litecqrs-php Summary
Small convention based CQRS library for PHP
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Execute the command - handler
- Registers command handlers .
- Create from array
- Commit events .
- Mark a field as a specific player .
- Generate UUID
- Save an object
- Invoke command handler
- Invokes the event handler .
- Registers an event handler
litecqrs-php Key Features
litecqrs-php Examples and Code Snippets
Community Discussions
Trending Discussions on litecqrs-php
QUESTION
I am trying to make CQRS event sourced app in PHP. And I wonder, is it ok to put aggregate root (AbstractItem
in following example) into event that is serialized in db? (I suppose no, but what is alternative?) For example I have command handler for AddItemToCartCommand
with this handle method:
ANSWER
Answered 2017-Mar-10 at 10:28Simple answer - you don't put an aggregate into an event.
An event represents a change in state. Rather than storing the current state of an aggregate, you capture what changed. This is your event. In your case, the id of the item added would be the minimum info required. Incidentally, I like to add more info into my events for convenience.
Why is storing an AR in an event bad?
An event is immutable. An AR is by definition mutable. An AR is also encapsulated which makes serialisation at best, awkward.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install litecqrs-php
This uses LiteCQRS\EventProviderInterface instances to trigger domain events. LiteCQRS knows about triggered events by asking LiteCQRS\Bus\EventQueue. Provide your own implementation to be independent of your domain objects having to implement EventProviderInterface.
In Memory Command Handlers, no event publishing/observing
In Memory Commands and Events Handlers
In Memory Commands + Custom Event Queue
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page