PHP code example of phauthentic / event-store
1. Go to this page and download the library: Download phauthentic/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/ */
phauthentic / event-store example snippets
use Phauthentic\EventStore\Event;
use Phauthentic\EventStore\InMemoryEventStore;
use Phauthentic\EventStore\ReplyFromPositionQuery;
$eventStore = new InMemoryEventStore();
$event = new Event(
aggregateId: 'order-123',
aggregateVersion: 1,
event: 'OrderCreated',
payload: ['amount' => 99.99],
createdAt: new \DateTimeImmutable()
);
$eventStore->storeEvent($event);
foreach ($eventStore->replyFromPosition(new ReplyFromPositionQuery('order-123', 1)) as $storedEvent) {
// Process event...
}