PHPackages                             event-sourcery/event-sourcery - 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. [Framework](/categories/framework)
4. /
5. event-sourcery/event-sourcery

ActiveLibrary[Framework](/categories/framework)

event-sourcery/event-sourcery
=============================

A Minimalistic PHP Event Sourcing / CQRS Library with GDPR Support

7.12(4y ago)651.5k6[1 PRs](https://github.com/event-sourcery/event-sourcery/pulls)2MITPHPPHP &gt;=7.4

Since May 11Pushed 1y ago8 watchersCompare

[ Source](https://github.com/event-sourcery/event-sourcery)[ Packagist](https://packagist.org/packages/event-sourcery/event-sourcery)[ RSS](/packages/event-sourcery-event-sourcery/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (64)Used By (2)

Event Sourcery PHP CQRS / ES Library
====================================

[](#event-sourcery-php-cqrs--es-library)

The Event Sourcing / CQRS framework whose core principle is keeping it simple.

**Library is under conceptual development. Do not use.**

This library is highly volatile and will change rapidly. It's being implemented into multiple production projects and will stabilize more soon.

Much of the implementation has been spiked and some of it is even untested. By release 1.0 the entire thing will be re-cut with lessons learned from using it in its current form.

Table of Contents
=================

[](#table-of-contents)

- [Core Values / Concepts (don't skip this)](#values)
- [Todo List](#todo-list)
- [Installation](#installation)
- [Framework Support](#framework-support)
    - [Laravel](#laravel)
    - [Symfony](#symfony)
    - [Others?](#others)
- [Components](#components)
    - [Values](#values-1)
        - [Serializable Value](#serializable-value)
        - [Serializable Personal Data Value](#serializable-personal-data-value)
    - [Entities](#entities)
        - [Entity IDs](#entity-ids)
    - [Aggregates](#aggregates)
    - [Domain Events](#domain-events)
        - [Serialization](#serialization)
    - [Commands](#commands)
    - [Event Store](#event-store)
    - [Event Dispatching and Listeners](#event-dispatching-and-listeners)
    - [Process Managers / Sagas](#process-managers)
    - [Projections](#projections)
- [Personal Data Security](#personal-data-security)
    - [Personal Keys](#personal-keys)
    - [Personal Data Store](#personal-data-store)
    - [Personal Cryptography Store](#personal-cryptography-store)
    - [Best Practices for Personal Data and Encryption Key Stores](#best-practices-for-personal-data-and-encryption-key-stores)
    - [Driver Implementations](#driver-implementations)
        - [Encryption Keys](#encryption-keys)
- [Notes](#notes)

Values
======

[](#values)

The core values / concepts are:

1. Reduce the amount of moving pieces that developers need to write / test.
2. Implement with simple idiomatic code that can easily be analyzed by your favorite IDE.
3. No custom event serialization. Push any serialization to value objects so that you implement and test serialiation once and not with every event you create.
4. Optional personal data value objects store into a separate data store. The event stays within the typical event store. Easily remove all personal data for an individual who invokes the 'right to erasure'.

Examples of working with personal data can be found in [PERSONAL\_DATA\_EXAMPLE.md](https://github.com/event-sourcery/event-sourcery/blob/master/PERSONAL_DATA_EXAMPLE.md).

Todo List
=========

[](#todo-list)

1. all commands are logged
2. commands / events get unique ids
3. all the other stuff
4. enterprise key management

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

[](#installation)

`composer require event-sourcery/event-sourcery`

Framework Support
=================

[](#framework-support)

Laravel
-------

[](#laravel)

The [Laravel driver](https://github.com/event-sourcery/laravel-event-sourcery-driver) can be found here.

Symfony
-------

[](#symfony)

Coming soon.

Others?
-------

[](#others)

Please [create an issue](https://github.com/event-sourcery/event-sourcery/issues) with the particular framework support request.

Components
==========

[](#components)

Values
------

[](#values-1)

Values represent things like names, temperature, ids, etc. Anything that uses value semantics derives from the following classes.

> Value semantics: equality is determined by comparing value, not ID.

1. `SerializableValue`
2. `SerializablePersonalDataValue`

The `SerializableValue` contract requires that you implement `serialize()` and `deserialize()` methods that will be used during domain event serialization.

The `PersonalData` contract tags the value as containing secure personal data that complies with our data protection policies. (is encrypted on persistence and can be erased in compliance with GDPR)

### Serializable Value

[](#serializable-value)

The `Serialization\SerializableValue` interface is used to provide to/from string serialization to value objects. This interface is used by the automatic domain-event and command serializer.

Any value that is of type `string`, `int`, `bool`, or extends `SerializableValue` will be able to be automatically stored and retrieved without custom event/command serialization code in userland.

This decision was made because it's easier to write / test the serialization of a value once than it is to test values N times where N is the number of events or commands that have to be written and individually tested.

```
