awd-studio / es-lib
An advanced event-sourcing library for PHP 8.3+ designed to handle domain events effectively.
Requires
- php: >=8.3
- awd-studio/vo-date-time: ^1.0
- psr/container: ^2.0
- symfony/uid: ^7.1
Requires (Dev)
- dg/bypass-finals: ^1.4
- ergebnis/composer-normalize: ^2.45
- phpspec/prophecy: ^1.20
- phpspec/prophecy-phpunit: ^2.3
- phpunit/phpunit: ^11.0
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2025-03-21 15:36:33 UTC
README
This is a PHP library designed to simplify the implementation of Event Sourcing patterns in your applications. It provides a robust set of tools and abstractions to manage aggregates, events, event storage, and snapshots, enabling you to build scalable, maintainable, and auditable systems.
What is Event Sourcing?
Event Sourcing is a design pattern where changes to an application's state are captured as a sequence of events. Instead of storing only the current state, the application maintains a history of all events that have occurred. This approach offers several advantages, including:
- Auditability: Every state change is recorded, providing a complete history.
- Scalability: Events can be processed asynchronously or in parallel.
- Reconstructability: Past states can be rebuilt by replaying events.
Features
- Aggregates: Manage domain entities with built-in support for event sourcing.
- Events: Define and handle domain events easily.
- Event Store: Persist and retrieve events from a configurable storage backend.
- Repositories: Simplify loading and saving aggregates.
- Snapshots: Optimize performance by storing snapshots of aggregate states.
Installation
You can install ES Lib via Composer:
composer install awd-studio/es-lib
Usage
Se the example section.
Integration
To use the library in your projects, you need to implement such interfaces:
# Storage / DB layer ## Reading \AwdEs\Event\Storage\Fetcher\EventFetcher::class \AwdEs\Event\Storage\Fetcher\Handling\CriteriaHandlingCase::class ## Writing \AwdEs\Event\Storage\Recorder\EventRecorder::class # Metadata ## Applying \AwdEs\Event\Applying\EventApplier::class ## Reading metadata \AwdEs\Event\Handling\EventHandlerMethodResolver::class \AwdEs\Meta\Event\EventMetadataResolver::class
License
This library is licensed under the MIT License. See the LICENSE file for details.