potfur / journal
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/potfur/journal
Requires
- php: >=5.6
Requires (Dev)
- league/tactician: ^1.0
- phpspec/phpspec: ^2.4
- phpunit/phpunit: ^5.2
- symfony/event-dispatcher: ^3.0
This package is not auto-updated.
Last update: 2025-11-09 01:25:31 UTC
README
Heavily inspired by EventCentric.Core event sourcing framework.
How does it work
Example is a simplified case of bank accounts with two basic actions: Deposit and Withdraw to increase and
decrease balance.
There is also a composite process - Transfer to show how sagas/process managers can be implemented.
Accountis a aggregate root, a class that is subject to actions from commands,- each action that has effect on
Accountwill create at least oneDomainEventinstance, describing what happened, eg.MoneyWereDepositedEventwhich says that some amount of money were deposited onAccount Accountstores those events in order of occurrence,UnitOfWorktracks events inAccount, and when it is committed - all new events will be sent toEventStore,EventStorewill store new events asEventStream- an immutable list of changes for this account.- when new action occurs,
UnitOfWorkwill reconstituteAccountfrom stored events, - when ever event is stored, event emitter sends it to all presenters so they can react to it,
- presenters
AccountHistoryPresenterandAccountBalancePresentersubscribe to events and update data for read models, eg. as reaction toMoneyWereDepositedEvent,AccountHistoryPresenterwill add new entry that says when and what amount was deposited.AccountBalancePresenterwill increase accounts balance.
Example uses Tactician for command bus and Event Dispatcher for emitting events, but they can be replaced with anything else.
Stuff that's missing
- snapshots
- more elaborate example
License
See LICENSE.