Download the PHP package twanhaverkamp/event-storage-in-mongodb-with-php without Composer

On this page you can find all versions of the php package twanhaverkamp/event-storage-in-mongodb-with-php. 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 event-storage-in-mongodb-with-php

Event storage in MongoDB with PHP

This package is a MongoDB implementation for the "Event Sourcing with PHP" library.

Table of Contents

Usage

Installation

Requirements:

If you're using Composer in your project you can run the following command:

Implementation

Most PHP frameworks like Symfony and Laravel allows you to register classes as services; If you like, you can register this Event store where you bind it to the EventStoreInterface.

Connect with MongoDB

When constructing the MongoDB client as first argument, an Event describer instance as second argument and your Database and Collection names as third and fourth arguments.

An Event describer can be found in the "Event Sourcing with PHP" library, which is automatically installed whenever you install this package. You can create your own Describer if you like; just make sure it implements the EventDescriberInterface, which can also be found in the "Event Sourcing with PHP" library.

Event registration

In order for the Event Store to know which type of Events exist, you need to register them in the Event Store:

You have to register your Events before actually using the Event Store.

Event storage

When you pass an Aggregate to the save function it loops over its Events and for every Event it will insert a new "document" for the constructed Database and Collection names.

Dependency injection

Laravel project

Create your own service provider when your working in a Laravel project to bind the MongoDB class to the EventStoreInterface:

Symfony project

If you're working in a Symfony project, you can leverage it's built-in "autowire" mechanism by registering the Event Store as a service in the services.yaml:


All versions of event-storage-in-mongodb-with-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-mongodb Version *
mongodb/mongodb Version ^2.1
twanhaverkamp/event-sourcing-with-php Version ^1.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 twanhaverkamp/event-storage-in-mongodb-with-php contains the following files

Loading the files please wait ...