PHP code example of lzakrzewski / http-event-store
1. Go to this page and download the library: Download lzakrzewski/http-event-store library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lzakrzewski / http-event-store example snippets
$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...