PHPackages                             phariscope/event-store - 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. [Templating &amp; Views](/categories/templating)
4. /
5. phariscope/event-store

ActiveLibrary[Templating &amp; Views](/categories/templating)

phariscope/event-store
======================

To develop event stores this package is start base.

2.1.0(2mo ago)03.7k↑73.8%1MITPHPPHP &gt;=8.1CI failing

Since Sep 25Pushed 2mo agoCompare

[ Source](https://github.com/phariscope/EventStore)[ Packagist](https://packagist.org/packages/phariscope/event-store)[ Docs](https://github.com/phariscope/EventStore)[ RSS](/packages/phariscope-event-store/feed)WikiDiscussions 2.x Synced 2d ago

READMEChangelog (9)Dependencies (28)Versions (19)Used By (1)

Installation
============

[](#installation)

```
composer require phariscope/event-store
```

Supported versions
------------------

[](#supported-versions)

Supported**PHP**`>=8.1` (Symfony 8 requires PHP `>=8.4` on the application side; Composer will resolve accordingly)**Symfony** (`config`, `dependency-injection`, `http-kernel`, `serializer`, `yaml`)6.4 LTS, 7.x, and 8.x per `composer.json`**phariscope/event**`>=1.2` (1.2.x is the reference line used in CI)Continuous integration runs PHPUnit against Symfony **6.4**, **7.4**, and **8.0** lines (see [`.github/workflows/ci.yml`](.github/workflows/ci.yml)).

Usage
=====

[](#usage)

There is no direct usage for this package. You should use this package only if you want to develop your own event storage component.

To develop your own storage:

1. Create your own Store implementing the StoreInterface.
2. Create your subscriber by extending PersistEventSubscriberAbstract, which can be constructed with your store.

Multiple implementations of the StoreInterface are provided:

- **StoreEventInMemory**: In-memory storage for testing and development
- **StoreEventInDatabase**: Persistent database storage using PDO
- **StoreEventWithMetrics**: Decorator adding performance monitoring to any store

### Using the SQLite persistence listener

[](#using-the-sqlite-persistence-listener)

A ready-to-use listener is provided to persist every event into a SQLite database (or any PDO-supported database) using `StoreEventInDatabase` under the hood.

Prerequisites:

- PHP with `pdo_sqlite` extension enabled (or another PDO driver if you use a different DBMS)

Example:

```
use Phariscope\EventStore\Persistence\PersistEventInDatabaseSubscriber;

// 1) Create a PDO connection (SQLite examples)
$pdo = new PDO('sqlite:/absolute/path/to/events.sqlite');
// or in-memory for tests/dev: new PDO('sqlite::memory:');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

// 2) Create the persistence listener (table auto-created if missing)
$persist = new PersistEventInDatabaseSubscriber($pdo, 'stored_events');

// 3) Use it as a PSR-14 listener/subscriber in your event system
// Registration depends on your dispatcher implementation.
// You can also invoke it directly:
// $persist->handle($yourEvent);
EventPublisher::instance()->subscribe($persist);

// 4) Access the underlying store when needed
$store = $persist->getStore();

// Fetch the last 10 stored events
$lastTen = $store->allStoredEventsSince(10);

// Fetch all events of a given type (optionally since a datetime or last N)
// $eventsByType = $store->getEventsByType(YourEvent::class);
```

Notes:

- The table is created automatically with the name you provide (default: `stored_events`).
- SQLite DSN formats:
    - `sqlite::memory:` for in-memory
    - `sqlite:/absolute/path/to/file.sqlite` for file-backed

### YAML configuration

[](#yaml-configuration)

You can configure the SQLite path and table name via a YAML file and build the listener from it.

Example `config/event_store.yaml`:

```
event_store:
  dsn: "sqlite:///absolute/path/to/events.sqlite"  # or ":memory:" for in-memory
  table_name: "stored_events"                      # optional (default: stored_events)
```

Bootstrap from configuration:

```
use Phariscope\EventStore\Config\EventStoreConfiguration;
use Phariscope\Event\Psr14\EventPublisher;

$config = EventStoreConfiguration::fromFile(__DIR__ . '/config/event_store.yaml');
$subscriber = $config->createSubscriber();

EventPublisher::instance()->subscribe($subscriber);
```

### Symfony Bundle integration

[](#symfony-bundle-integration)

If you are using Symfony, enable the bundle and configure it under `config/packages/event_store.yaml`:

1. Register the bundle (Symfony Flex may do this automatically):

```
// config/bundles.php
return [
    // ...
    Phariscope\EventStore\Bridge\Symfony\EventStoreBundle::class => ['all' => true],
];
```

2. Configure the package:

```
# config/packages/event_store.yaml
event_store:
  dsn: "sqlite:///absolute/path/to/events.sqlite"  # or ":memory:"
  table_name: "stored_events"                      # optional
```

Services exposed:

- `phariscope_event_store.pdo`: configured `PDO` instance
- `phariscope_event_store.subscriber`: `PersistEventInDatabaseSubscriber`

Additional features include:

- **Event versioning** with VersionedEvent for schema evolution
- **Performance metrics** tracking with EventStoreMetrics
- **Event filtering** by type and time ranges
- **Comprehensive API documentation** in docs/API.md

To Contribute to phariscope/Event
=================================

[](#to-contribute-to-phariscopeevent)

Requirements
------------

[](#requirements)

- docker
- git

Install
-------

[](#install)

- git clone :phariscope/EventStore.git

Unit test
---------

[](#unit-test)

```
bin/phpunit
```

Using Test-Driven Development (TDD) principles (thanks to Kent Beck and others), following good practices (thanks to Uncle Bob and others) and the great book 'DDD in PHP' by C. Buenosvinos, C. Soronellas, K. Akbary

Quality
-------

[](#quality)

- phpcs PSR12
- phpstan level 9
- coverage 100%
- infection MSI 100%

Quick check with:

```
./codecheck
```

Check coverage with:

```
bin/phpunit --coverage-html var
```

and view 'var/index.html' with your browser

Check infection with:

```
bin/infection
```

and view 'var/infection.html' with your browser

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance86

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 92.9% 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.

###  Release Activity

Cadence

Every ~55 days

Total

18

Last Release

75d ago

Major Versions

1.x-dev → 2.0.02025-08-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/b55e08523b4e1c881655796925ea5ac3ed5d997b533185be986b4a0e0d4f73c4?d=identicon)[fredlogipro](/maintainers/fredlogipro)

---

Top Contributors

[![frederic100](https://avatars.githubusercontent.com/u/50176793?v=4)](https://github.com/frederic100 "frederic100 (26 commits)")[![brudert](https://avatars.githubusercontent.com/u/74777353?v=4)](https://github.com/brudert "brudert (2 commits)")

---

Tags

templating

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phariscope-event-store/health.svg)

```
[![Health](https://phpackages.com/badges/phariscope-event-store/health.svg)](https://phpackages.com/packages/phariscope-event-store)
```

###  Alternatives

[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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