MongoDB adapter
domainflow/event-sourcing-mongodb implements the Event Sourcing Core storage
contracts against MongoDB. It contains no aggregate or business logic; it
translates Core events, snapshots, process-manager state, and outbox entries
to MongoDB documents.
Components
| Component | Responsibility |
|---|---|
MongoDbEventStorage | Event streams, global reads, concurrency, transactions, and optional outbox enrollment |
MongoDbEventEntryFactory | Native BSON payload and metadata documents, plus event reconstruction |
MongoDbSnapshotStorage | Latest snapshot per aggregate |
MongoDbSnapshotHistoryStorage | Versioned snapshot history |
MongoDbProcessManagerStorage | Versioned process-manager state and timeout lookup |
MongoDbOutboxStorage | Claimable outbox entries and abandoned entries |
MongoDbSchemaManager | Required collections and indexes |
Requirements
- PHP 8.4+
ext-mongodbmongodb/mongodb2.x- MongoDB 7+ reachable by the application
The default write path requires MongoDB to run as a replica set. A single-node replica set is sufficient for local development.
Installation
composer require domainflow/event-sourcing-mongodb
The package requires domainflow/event-sourcing-core ^0.1.0.
Documentation
- Installation and schema setup
- Transactions, BSON, snapshots, and outbox
- MongoDB-specific operations and testing
The Core documentation explains aggregate modeling and the storage interfaces implemented here.