PHP
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
data/cache
public
src
tests
.coveralls.yml
.docheader
.gitattributes
.gitignore
.php_cs
.travis.yml
LICENSE
README.md
composer.json.dist
docker-compose.yml.dist
phpunit.xml.dist

README.md

Prooph EventStore HTTP API

Build Status Coverage Status Gitter

Overview

Prooph Event Store is capable of persisting event messages that are organized in streams. Prooph\EventStore\EventStore itself is a facade for different persistence adapters (see the list below) and adds event-driven hook points for Prooph\EventStore\Plugin\Plugins which make the Event Store highly customizable.

The HTTP API is a standalone software that exposes event streams via HTTP protocol.

Installation

  1. cp composer.json.dist composer.json cp config/pipeline.php.dist config/pipeline.php cp config/autoload/event_store.local.php.dist config/autoload/event_store.local.php

Make your adjustments.

open your database console and create a database

create your event streams table, see: https://github.com/prooph/pdo-event-store/tree/master/scripts

php -S 0.0.0.0:8080 -t public/.

Writing to streams

Open a text file "foo.txt" and put the following content:

[
  {
    "uuid": "f9fea0b9-bbab-41ad-b3c1-56e09a1044a4",
    "created_at": "2016-11-12T14:35:41.702700",
    "message_name": "event-type",
    "payload": {
      "a": "2"
    },
    "metadata":{"_aggregate_version":1}
  },
  {
    "message_name":"foo",
    "payload":{"b" : "c"},
    "metadata":{"_aggregate_version":2}
  }
]

Then run this command:

curl -i -d @foo.txt http://localhost:8080/stream/Prooph%5CModel%5CUser -H "Content-Type: application/vnd.eventstore.atom+json"

You should see:

HTTP/1.1 201 Created

And on a second request due to duplicate _aggregate_version:

HTTP/1.1 500 Cannot create or append to stream

Reading from streams

curl -i http://localhost:8080/streams/Prooph%5CModel%5CUser/1 -H "Accept: application/vnd.eventstore.atom+json"

curl -i http://localhost:8080/streams/Prooph%5CModel%5CUser/11/forward/20 -H "Accept: application/vnd.eventstore.atom+json"

curl -i http://localhost:8080/streams/Prooph%5CModel%5CUser/71/backward/42 -H "Accept: application/vnd.eventstore.atom+json"

curl -i http://localhost:8080/streams/Prooph%5CModel%5CUser/head/backward/2 -H "Accept: application/vnd.eventstore.atom+json"

Support

Contribute

Please feel free to fork and extend existing or add new plugins and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.

License

Released under the New BSD License.