- Download/Installation:
- on Ubuntu:
sudo service eventstore start - Admin GUI: http://127.0.0.1:2113 (admin:changeit)
- When eventstore is installed on host instead of in the virtualbox, use port forwarding:
vagrant ssh -- -R 2113:localhost:2113
- Introduction: http://docs.geteventstore.com/introduction/
- Store events to a stream:
- streams are automatically created by posting data for the stream name
- general format:
[ { "eventId": "…", "eventType": "…", "data": {…}, "metadata": {…} } ](plus UUID if PUTing is used) - POSTing single events is assumed when content type is
application/jsonorapplication/xml - POSTing multiple events:
curl -i -d @testevents.txt "http://127.0.0.1:2113/streams/newstream" -H "Content-Type:application/vnd.eventstore.events+json" - Single event POSTing allows to set
eventTypeandeventIdvia headersES-EventTypeandES-EventId:curl -i -d @singleevent.txt "http://127.0.0.1:2113/streams/shop" -H "Content-Type: application/json" -H "ES-EventType: HelloCreated" -H "ES-EventId: 8f5ff3e6-0e26-4510-96c4-7e61a270e6f6"
- Read streams:
- as Atom XML feed:
curl -i -H "Accept:application/atom+xml" "http://127.0.0.1:2113/streams/newstream" - as Atom JSON feed:
curl -i -H "Accept: application/vnd.eventstore.atom+json" "http://127.0.0.1:2113/streams/newstream" - single event payload as json:
curl -i -H "Accept: application/json" http://127.0.0.1:2113/streams/newstream/0
- as Atom XML feed:
- Setup ACL for a stream via the streams' metadata:
- Media types:
application/vnd.eventstore.events+jsonandapplication/vnd.eventstore.events+xmlapplication/jsonandapplication/xmlandtext/xml
- Projections
- used to query streams and create new persistent ones if needed
- when creating a projection one can specify whether to run it for history and stop or to run for the history and continue
- there are two standard projections built-in:
$by_categoryfor all events that have the same prefix (separator is-)by_event_typefor all events that have the sametype- e.g.:
fromCategory('foo')gets all events from all streams starting with namefoo-
- general format:
fromStream("stream").when({ $init: f0, Event1: f1, Event2: f2, $any: f3 }); - use
$initfunction to set initialstatefor your projection $anywill match all events to your function (useful when not caring for the actual event type as e.g. general metadata is interesting)- emit events to streams:
emit("stream", "eventtype", eventdata) - emit w/o copy:
linkTo("stream", event)doesn't actually write the event to the stream, but emits a pointer to the event to the stream (which doesn't make a difference when fetching the stream) - List existing projections:
curl -i 'http://localhost:2113/projections/any' - Show state of specific projection:
curl -i 'http://localhost:2113/projection/$foo/state' - Show query of specific projection:
curl -i 'http://localhost:2113/projection/$foo/query' - Change query of projection:
curl -i -X PUT -d @proj.js 'http://localhost:2113/projection/$foo/query' - create transient projection:
curl -i -d @projection-foo.js http://127.0.0.1:2113/projections/transient?enabled=yes -u admin:changeit -H "Content-Type: application/json"– response contains projection name to querycurl -i http://127.0.0.1:2113/projection/uuid - create projection:
curl -i -d @projection-foo.js 'http://127.0.0.1:2113/projections/continuous?name=$foo&enabled=yes&emit=yes&checkpoints=yes' -u admin:changeit -H "Content-Type: application/json"(alternative tocontinuousisonetime)
- Subscriptions
- Live-only subscriptions
- Catch-up subscriptions
- Configuration read order
- Command Line Parameter (Most important)
- Environment Variable
- Configuration File
- Default (Least important)
Links/Sources:
- https://geteventstore.com/blog/
- http://docs.geteventstore.com/
- client: https://github.com/FriendsOfOuro/geteventstore-php-core
- above client w/ projection support: https://github.com/tetsuobe/php-eventstore-client
- client for event store TCP api: https://github.com/madkom/event-store-client
- a php7 client: https://github.com/rayrutjes/php-geteventstore-client
- https://groups.google.com/forum/#!forum/event-store
- http://www.ustream.tv/recorded/46673907
- http://blog.arkency.com/2015/03/your-solid-tool-for-event-sourcing-eventstore-examples/
- https://gist.github.com/graste/eebb6bf73b4226e47dcabfaa39f6a307
- Google protobuf v3+ brings php support as php package and extension for proto3 syntax https://github.com/google/protobuf/tree/master/php
Forks of https://github.com/FriendsOfOuro/geteventstore-php-core:
- https://github.com/ohader/geteventstore-php-core
- https://github.com/robertlemke/php-eventstore-client/commits/robertlemke
- https://github.com/jdextraze/php-eventstore-client/commits/bugfixes
- https://github.com/vmeretail/php-eventstore-client
- https://github.com/madedotcom/php-eventstore-client