PHPackages                             patchlevel/event-sourcing-psr-container - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. patchlevel/event-sourcing-psr-container

ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

patchlevel/event-sourcing-psr-container
=======================================

event sourcing factories for PSR-11 containers

00[10 PRs](https://github.com/patchlevel/event-sourcing-psr-container/pulls)PHP

Since Mar 15Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/patchlevel/event-sourcing-psr-container)[ Packagist](https://packagist.org/packages/patchlevel/event-sourcing-psr-container)[ RSS](/packages/patchlevel-event-sourcing-psr-container/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (14)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/7b484df5dd400a460dd649952d49f9a4326b804501b39a97dea9eb4756b6a72c/68747470733a2f2f706f7365722e707567782e6f72672f70617463686c6576656c2f6576656e742d736f757263696e672d7073722d636f6e7461696e65722f76)](//packagist.org/packages/patchlevel/event-sourcing-psr-container)[![License](https://camo.githubusercontent.com/5363f54ed446e4c6e87f0c27380cddcf94c725b517eac57226d0321afedac8f7/68747470733a2f2f706f7365722e707567782e6f72672f70617463686c6576656c2f6576656e742d736f757263696e672d7073722d636f6e7461696e65722f6c6963656e7365)](//packagist.org/packages/patchlevel/event-sourcing-psr-container)

Event-Sourcing PSR-11 Container
===============================

[](#event-sourcing-psr-11-container)

[patchlevel/event-sourcing](https://github.com/patchlevel/event-sourcing) factories for PSR-11 containers.

Installation
------------

[](#installation)

```
composer require patchlevel/event-sourcing-psr-container
```

Documentation
-------------

[](#documentation)

### Config Builder

[](#config-builder)

To create a configuration array, you can use the ConfigBuilder. This offers methods to adjust the configuration.

```
$eventSourcingConfig = (new ConfigBuilder())
    ->singleTable()
    ->databaseUrl('mysql://user:secret@localhost/app')
    ->addAggregatePath(__DIR__ . '/Aggregate')
    ->addEventPath(__DIR__ . '/Events')
    ->addProcessor(SendEmailProcessor::class)
    ->addProjector(ProfileProjection::class)
    ->build();
```

### Default Build-In Container

[](#default-build-in-container)

The own PSR container implementation already integrates all necessary factories. So we only have to pass the configuration.

```
use Patchlevel\EventSourcing\Container\ConfigBuilder;
use Patchlevel\EventSourcing\Container\DefaultContainer;

$container = new DefaultContainer(
    $eventSourcingConfig,
    [
        HotelProjection::class => fn(DefaultContainer $container)
            => new HotelProjection($container->connection()),
        SendEmailProcessor::class => fn(DefaultContainer $container)
            => new SendEmailProcessor($container->get('mailer')),
    ]
);

$container->get(SchemaDirector::class)->create();

$hotelRepository = $container->repository(Hotel::class);
```

### Laminas Service Manager

[](#laminas-service-manager)

Factories can also be used with other PSR-11 compatible libraries. Here is an example with [Laminas](https://docs.laminas.dev/laminas-servicemanager/).

```
composer require laminas/laminas-servicemanager
```

We only have to specify the factories and pass the configuration.

```
use Laminas\ServiceManager\ServiceManager;
use Patchlevel\EventSourcing\Repository\RepositoryManager;
use Patchlevel\EventSourcing\Schema\SchemaDirector;
use Patchlevel\EventSourcingPsrContainer\ConfigBuilder;
use Patchlevel\EventSourcingPsrContainer\Factory\ConnectionFactory;
use Patchlevel\EventSourcingPsrContainer\Factory\RepositoryManagerFactory;
use Patchlevel\EventSourcingPsrContainer\Factory\SchemaDirectorFactory;

$serviceManager = new ServiceManager([
    'services' => [
        'config' => [
            'event_sourcing' => $eventSourcingConfig
        ],
        SendEmailProcessor::class => new SendEmailProcessor()
    ],
    'factories' => [
        'event_sourcing.connection' => new ConnectionFactory(),
        RepositoryManager::class => new RepositoryManagerFactory(),
        SchemaDirector::class => new SchemaDirectorFactory(),
        HotelProjection::class => static fn (ServiceManager $container) => new HotelProjection($container->get('event_sourcing.connection')),
    ],
]);

$serviceManager->get(SchemaDirector::class)->create();

$repositoryManager = $serviceManager->get(RepositoryManager::class);
$hotelRepository = $repositoryManager->get(Hotel::class);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance59

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 58.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/470138?v=4)[David Badura](/maintainers/DavidBadura)[@DavidBadura](https://github.com/DavidBadura)

---

Top Contributors

[![DavidBadura](https://avatars.githubusercontent.com/u/470138?v=4)](https://github.com/DavidBadura "DavidBadura (14 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (9 commits)")[![DanielBadura](https://avatars.githubusercontent.com/u/2017762?v=4)](https://github.com/DanielBadura "DanielBadura (1 commits)")

### Embed Badge

![Health badge](/badges/patchlevel-event-sourcing-psr-container/health.svg)

```
[![Health](https://phpackages.com/badges/patchlevel-event-sourcing-psr-container/health.svg)](https://phpackages.com/packages/patchlevel-event-sourcing-psr-container)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
