Download the PHP package mad654/php-event-store without Composer

On this page you can find all versions of the php package mad654/php-event-store. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-event-store

PHP Event Store

Plain php event store implementation for easy persistence by utilizing event sourcing.

It provides classes to express object state changes as events and store them in file based eventstreams.

Installation

You can install mad654/php-event-store via composer by adding "mad654/php-event-store": "dev-master" as requirement to your composer.json.

By Example

For a full working example take a look at src/example. In your vagrant box you can use it like this:

Step by step

Let's take this little example to get in touch with all the new stuff. Lets asume you want to control the light in your Kittchen and for this you have build some switch. All you need is an object which can control the state and keeps its current state over mutlitple requests:

This is a good beginning, but now you need a way to persist the state.

EventSourcedObject

Instead of creating a database you can extend your class to implement the EventSourcedObject interface. An EventSourcedObject is simply an object which should be available in his current state in the next request and for this it can publish its events as a stream and can be build from scratch based on the events:

So instead of changing your member variables directly, you will use events for this, like shown in switchOn. So you will record an event and you will update your state in the on function, which is automatically be called by record function.

If you want to see more details, take a look at the AutoTrackingEventSourcedObjectTrait which should be a good starting point for all your event sourced objects and reduce boilerplate code.

EventSourcedObjectStore

The EventSourcedObjectStore provides a simple API which allows you to save and load objects which implements the EventEmitter interface:

If '$someEventSourcedObject' was implemented correctly, it should have the equal state - before and after the unset() call.

By definition an EventSourcedObjectStore can only store and retrieve objects by id. Here you can find solutions for searching ...

Event

In this example we use the StateChanged event, in production you should create subclasses of this to express more precisely what happened.

In general events are immutable.

Putting all together

Some times later in an other request you want to switch on the light in the kitchen:

And again later you will switch it off again:

And again ...

And again ...

And now you are wondering why your power bill is so expensive - let's take a look at the history:

Development

Inside of the vagrant box:


All versions of php-event-store with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
psr/log Version ^1.1
consolidation/log Version ^1.1
ext-json Version *
dflydev/dot-access-data Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mad654/php-event-store contains the following files

Loading the files please wait ....