Download the PHP package neos/eventstore without Composer

On this page you can find all versions of the php package neos/eventstore. 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 eventstore

General purpose event store

This package provides interfaces and helpers to create Event-Sourced systems with PHP

Scope

In contrast to Neos.EventSourcing this package provides merely the low-level building blocks, has just a couple of dependencies and is less opinionated.

[!NOTE] This package mostly contains interfaces and implementations of Data Transfer Objects. To actually persist events, a corresponding adapter package is required, for example neos/eventstore-doctrineadapter

Usage

Install via composer:

Appending events

Commit a single event to the event store

Commit multiple events at once

Note Multiple events can only ever be appended to the same stream at once

Expected version

Event-sourced systems are eventual consistent. This basically means that the models, that are used to base decisions on, might be out of date. The ExpectedVersion can be used to make sure, that no new events where appended to the stream since the model was reconstituted from the events. That mechanism can be used to implement event-sourced aggregates.

ExpectedVersion::ANY

ExpectedVersion::ANY() (as used in the examples above) skips the version check entirely and should only be used if no hard constraints are required.

ExpectedVersion::NO_STREAM

ExpectedVersion::NO_STREAM() can be used to make sure that a given stream does not yet exist. This is useful for events that represent the creation of an entity:

If the same code was executed again (with the same $customId) it would fail

ExpectedVersion::STREAM_EXISTS

ExpectedVersion::STREAM_EXISTS() is basically the opposite of NO_STREAM: It fails if no events have been committed to the stream before

Reading events

Iterate over all events of a stream

To load all events and output their sequence number and type:

Filter event stream

EventStoreInterface::load() expects a second, optional, argument that allows to filter the event stream. This can be used to only load events of a certain type:

[!NOTE] Filtering events based on their type is a low-level optimization that is usually not required and should only be applied if needed

Navigate the event stream

The resulting EventStreamInterface of the EventStoreInterface::load() call is a lazy representation of the stream. Depending on the actual implementation the events are only loaded whenever they are accessed.

The EventStreamInterface provides four methods to affect ordering and window of the events to load:

Usually the withMinimumSequenceNumber() is used to only load events that have not been processed yet by an event handler, but sometimes it can be useful to allow for arbitrary event stream navigation.

The following example will read at most 10 events with sequence number between 500 and 1000 in descending order:

Deleting events

Events form the unique source of truth in a system and thus should never be deleted. In theory. In practice, it can be useful to be able to remove streams that are not in use any longer.

The following example deletes all events from "some-stream":

[!WARNING] For obvious reasons, this method should only be used with great care. Mostly there are better ways to solve issues that seem to require deletion of events. Also note, that some Event store implementations might not support this feature

More examples

@see tests for more examples.

Contribution

Contributions in the form of issues, pull requests or discussions are highly appreciated

License

See LICENSE


All versions of eventstore with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
webmozart/assert Version ^1.10
ramsey/uuid Version ^4.3
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 neos/eventstore contains the following files

Loading the files please wait ....