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.0.4(7mo ago)03.1k↓50%1MITPHPPHP &gt;=8.1

Since Sep 25Pushed 7mo 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 1mo ago

READMEChangelog (8)Dependencies (13)Versions (18)Used By (1)

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

[](#installation)

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

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

41

—

FairBetter than 89% of packages

Maintenance62

Regular maintenance activity

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 92.6% 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 ~45 days

Recently: every ~1 days

Total

17

Last Release

238d 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 (25 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

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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