Giter Club home page Giter Club logo

prooph-v7-event-store's Introduction

event-engine/prooph-v7-event-store

Event Engine Prooph V7 Event Store Bindings

Installation

composer require event-engine/prooph-v7-event-store

Prooph Binding

tbd

InMemoryEventStore

tbd

FilesystemEventStore

A prooph v7 compatible FilesystemEventStore is included, too. It is meant to be used for demonstration purpose only (for example in a workshop).

//Basic set up that's able to handle Prooph\Common\Messaging\DomainEvent
$filesystemEventStore = new \EventEngine\Prooph\V7\EventStore\FilesystemEventStore(
    'data/prooph.event_store.json', 
    \JSON_PRETTY_PRINT
    // optional MessageFactory -> defaults to FQCNMessageFactory
    // optional MessageConverter -> defaults to NoOpMessageConverter
);

//Create an empty stream
$filesystemEventStore->create(
    new \Prooph\EventStore\Stream(
        new \Prooph\EventStore\StreamName('event_stream'), 
        new ArrayIterator()
    )
);

//Can also be used together with an InMemoryProjectionManager
$projectionManager = new \EventEngine\Prooph\V7\EventStore\Projecting\InMemory\InMemoryProjectionManager(
    $filesystemEventStore,
    new \EventEngine\Persistence\InMemoryConnection()
);

$query = $projectionManager->createQuery();

$query->fromStream('event_stream')
    ->whenAny(function (array $state, \Prooph\Common\Messaging\DomainEvent $event) {
        echo "{$event->messageName()} stored in event_stream\n";
    });

$query->run();

Please Note: The combination of FilesystemEventStore and InMemoryProjectionManager has the drawback that projections only see events that are in the event store at the time of running the projection. If other PHP processes add events to the store, those are first visible for the projection after restarting the PHP process and running the projection again. We might add a FilesystemProjectionManager in the future, if needed.

prooph-v7-event-store's People

Contributors

arnedesmedt avatar codeliner avatar sandrokeil avatar zluiten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.