Skip to content

lzakrzewski/http-event-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HttpEventStore

Build Status Latest Unstable Version Total Downloads

Client for communication with Event Store HTTP API. Read more about Event Store HTTP API http://docs.geteventstore.com/http-api/latest.

This library is independent part of es-sandbox.

Requirements

  "require": {
    "php": ">=5.6",
    "guzzlehttp/guzzle": "~6.0",
    "ramsey/uuid" : "~3.0"
  }

Installation

Require the library with composer:

composer require lzakrzewski/http-event-store

Usage

Example

$streamId = Uuid::uuid4()->toString();

$eventStore = \HttpEventStore\Http\HttpEventStore::create('127.0.0.1', '2113');
$event1     = new \HttpEventStore\WritableEvent('productWasAddedToBasket', ['productId' => 'product1', 'name' => 'Teapot']);
$event2     = new \HttpEventStore\WritableEvent('productWasRemovedFromBasket', ['productId' => 'product1']);

// Writing to a Stream
$eventStore->writeStream($streamId, [$event1, $event2]);

// Reading from a Stream
$events = $eventStore->readStream($streamId);

 // Your logic with events there...