How inwebo/doctrine-event-sourcing works
This is a Doctrine event-sourcing library: applications mark aggregate roots and tracked properties, then Doctrine lifecycle events create state snapshots; the library also applies snapshots and resolves historical changes. The graph preserves configuration, state management, and history as distinct capabilities. Source excerpts show the listener, mapping, aggregation, and diff behavior; README statements support the documented Doctrine setup and persistence workflow. The resolver and DTOs are represented, but no storage implementation is shown—the application’s Doctrine setup owns persistence.
Main entry points: MappingFactory.php Mapping factory · Aggregator.php State aggregator · DiffResolver.php History diff resolver · AbstractStoreListener.php Store listener
Components 16
Mapping configuration
- Aggregate root attribute
src/Mapping/AggregateRoot.php - Tracked property attribute
src/Mapping/AggregateSource.php - Mapping factory
src/Model/MappingFactory.php - Property mapping
src/Model/Mapping.php - Mapping validation errors
src/Exception/Mapping - Interface validation error
src/Exception/MissingHasStatesInterfaceException.php
Snapshot lifecycle
- Aggregate and state contracts
src/Model/Interface - State aggregator
src/Model/Aggregator.php - Store listener
src/Listener/AbstractStoreListener.php - Default listener
src/Listener/StoreListener.php - State snapshots
History and changes
- History diff resolver
src/Resolver/DiffResolver.php - Individual change
src/Model/Dto/ChangeDto.php - Change set
src/Model/Dto/ChangeSetDto.php
Other components
- Application entities
- Doctrine ORM
Connections 19
- Application entities → Aggregate root attribute: marks root
README.md - Application entities → Tracked property attribute: marks properties
README.md - Doctrine ORM → Default listener: dispatches lifecycle events
README.md - Default listener → Store listener: inherits behavior
src/Listener/StoreListener.php - Store listener → State aggregator: creates snapshots
src/Listener/AbstractStoreListener.php - Store listener → State snapshots: persists snapshots
README.md - Mapping factory → Aggregate root attribute: reads configuration
src/Model/MappingFactory.php - Mapping factory → Tracked property attribute: reads configuration
src/Model/MappingFactory.php - Mapping factory → Property mapping: builds mappings
src/Model/MappingFactory.php - Mapping factory → Mapping validation errors: reports invalid mapping
src/Model/MappingFactory.php - Mapping factory → Interface validation error: checks contract
src/Model/MappingFactory.php - Mapping factory → Aggregate and state contracts: validates contracts
src/Model/MappingFactory.php - State aggregator → Mapping factory: uses mappings
src/Model/Aggregator.php - State aggregator → Property mapping: transfers property values
src/Model/Aggregator.php - State aggregator → Aggregate and state contracts: creates and applies states
src/Model/Aggregator.php - History diff resolver → State aggregator: builds current snapshot
src/Resolver/DiffResolver.php - History diff resolver → Aggregate and state contracts: reads state history
src/Resolver/DiffResolver.php - History diff resolver → Individual change: records differences
src/Resolver/DiffResolver.php - History diff resolver → Change set: assembles changes
src/Resolver/DiffResolver.php