lzakrzewski/http-event-store

Client for communication with event store http api

0.0.5 2016-06-08 06:18 UTC

This package is not auto-updated.

Last update: 2024-11-18 12:39:29 UTC


README

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...