Skip to main content

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

ComponentResponsibility
MongoDbEventStorageEvent streams, global reads, concurrency, transactions, and optional outbox enrollment
MongoDbEventEntryFactoryNative BSON payload and metadata documents, plus event reconstruction
MongoDbSnapshotStorageLatest snapshot per aggregate
MongoDbSnapshotHistoryStorageVersioned snapshot history
MongoDbProcessManagerStorageVersioned process-manager state and timeout lookup
MongoDbOutboxStorageClaimable outbox entries and abandoned entries
MongoDbSchemaManagerRequired collections and indexes

Requirements

  • PHP 8.4+
  • ext-mongodb
  • mongodb/mongodb 2.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

The Core documentation explains aggregate modeling and the storage interfaces implemented here.