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.
"require": {
"php": ">=5.6",
"guzzlehttp/guzzle": "~6.0",
"ramsey/uuid" : "~3.0"
}
Require the library with composer:
composer require lzakrzewski/http-event-store
$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...