Skip to content

Repository files navigation

PHP Event Store Client library for GetEventStore

This is a draft, work in progress, an experiment of implementation of a client library for GetEventStore abstracting transport and aimed to work with both the Protobuf protocol or the HTTP API.

It is heavily inspired (and by some accounts generated from) the .NET client library.

Requirements

  • PHP >= 5.4

1. Quick start

2. Overview

Theory of operations

Low-level operations example

This is an example of a low level operations.

the makeOperation of the Transport makes a transactional operation to the Event Store. This means you may commit several events at once transactionally.

This API is not aimed to be used directly but through a Façade which would abstract some inner mechanism relevant to how the GetEventStore storage works.

<?phprequire'vendor/autoload.php';
$httpClient = new \Bgy\EventStore\Transport\Http\HttpClient();
$transport = new \Bgy\EventStore\Transport\Http\HttpTransport($httpClient);
class User {
public$id;
}
$user = newUser();
$user->id = Uuid::generate();
$transport->makeOperation(
new \Bgy\EventStore\Operation\AppendToStreamOperation(
true,
'users-' . (string) $user->id,
\Bgy\EventStore\ExpectedVersion::ANY,
[
new \Bgy\EventStore\EventData(
new \Bgy\EventStore\Utils\Uuid(),
'UserRegistered',
newUserRegistered($uuid ),
[]
),
]
,
null
)
);
$transport->makeOperation(
new \Bgy\EventStore\Operation\AppendToStreamOperation(
true,
'users-' . (string) $user->id,
\Bgy\EventStore\ExpectedVersion::ANY,
[
new \Bgy\EventStore\EventData(
new \Bgy\EventStore\Utils\Uuid(),
'UserJoinedGroup',
newUserJoinedGroup(newGroup('admin')),
[]
),
new \Bgy\EventStore\EventData(
new \Bgy\EventStore\Utils\Uuid(),
'UserLeftGroup',
newUserLeftGroup(newGroup('admin')),
[]
),
new \Bgy\EventStore\EventData(
new \Bgy\EventStore\Utils\Uuid(),
'UserJoinedGroup',
newUserJoinedGroup(newGroup('admin')),
[]
)
]
,
null
)
);

3. Operations

4. Contributing

  1. Take a look at the list of issues.
  2. Fork
  3. Write a test (for either new feature or bug)
  4. Make a PR

5. Authors

6. License

Event Store For PHP is licensed under the MIT License - see the LICENSE file for details

The Big Brains Company - Logo

About

PHP Event Store Client Library for GetEventStore

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages