Download the PHP package lidskasila/glow without Composer

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

PHP Glow library

This library is to show another way to tackle CQRS and event sourcing, but is not considered as suitable for real production projects. For this purpose rather use Prooph toolbox or Nette extension for Prooph toolbox. It supports snapshoting, read model projections, is easy to make event replaying and is way more flexible.

This PHP CQRS EventSourcing library is based on Benjamin Eberlei's LiteCQRS for php which was not maintained for quite a long time. This fork is bringing it back to life, but it is not to be considered as a stable library, since there may be BC breaks in the near future.

Build Status Quality Score Code Coverage Downloads this Month

Main differences are:

Original updated readme

Small naming-convention based CQRS library for PHP (loosely based on LiteCQRS for C#) that relies on the MessageBus, Command, EventSourcing and Domain Event patterns.

Terminology

CQS is Command-Query-Separation: A paradigm where read methods never change state and write methods never return data. Build on top, CQRS suggests the separation of read- from write-model and uses the DomainEvent pattern to notify the read model about changes in the write model.

Glow uses the command pattern and a central message bus service that finds the corresponding handler to execute a command. A command must implement Glow\Commanding\Command. It should be a plain DTO (data transfer object) with just some properties describing it (imutability is encouraged).

After this object is passed as a parameter into the CommandBus' handle(Command $command) method, CommandBus finds a proper CommandHandler and invokes the same method with the same parameter on it. Enforced convention is that there has to be XxxCommandHandler (implementing CommandHandler) for every XxxCommand.

During the execution of a command, domain events can be triggered. These are again just simple classes with some properties and they can optionally implement Glow\DomainEvent.

An event queue knows what domain events have been triggered during a command and then publishes them to an event message bus, where many listeners can listen to them.

Changes

Conventions

Examples:

Installation & Requirements

Install with Composer:

composer require lidskasila/glow

Workflow

These are the steps that a command regularly takes through the Glow stack during execution:

  1. You push commands into a CommandBus. Commands are simple objects implementing Command created by you.
  2. The CommandBus checks for a handler that can execute your command. Every command has exactly one handler.
  3. The command handler changes state of the domain model. It does so by creating events (that represent a state change) and passing them to the AggregateRoot::apply() or DomainEventProvider::raise() method of your domain objects.
  4. When the command is completed, the command bus will check all objects in the identity map for events.
  5. All found events will be passed to the EventMessageBus#publish() method.
  6. The EventMessageBus dispatches all events to observing event handlers.
  7. Event Handlers can create new commands again using the CommandBus.

Command and Event handler execution can be wrapped in handlers that manage transactions. Event handling is always triggered outside of any command transaction. If the command fails with any exception all events created by the command are forgotten/ignored. No event handlers will be triggered in this case.

In the case of InMemory CommandBus and EventMessageBus Glow makes sure that the execution of commands and event handlers is never nested, but in sequential linearized order. This prevents independent transactions for each command from affecting each other.

TODO following is not updated

Examples

See examples/ for some examples:

  1. example1.php shows usage of the Command- and EventMessageBus with one domain object
  2. example2_event.php shows direct usage of the EventMessageBus inside a command
  3. example3_sequential_commands.php demonstrates how commands are processed sequentially.
  4. tictactoe.php implements a tic tac toe game with CQRS.
  5. SymfonyExample.md shows example1.php implemented within the scope of a Symfony2 project.

Setup

  1. In Memory Command Handlers, no event publishing/observing

  2. In Memory Commands and Events Handlers

This uses Glow\EventProviderInterface instances to trigger domain events.

  1. In Memory Commands + Custom Event Queue

Glow knows about triggered events by asking Glow\Bus\EventQueue. Provide your own implementation to be independent of your domain objects having to implement EventProviderInterface.

Usage

To implement a Use Case of your application

  1. Create a command object that receives all the necessary input values. Use public properties and extend Glow\DefaultCommand to simplify.
  2. Add a new method with the name of the command to any of your services (command handler)
  3. Register the command handler to handle the given command on the CommandBus.
  4. Have your entities implement Glow\AggregateRoot or Glow\DomainEventProvider
  5. Use protected method raise(DomainEvent $event) or apply(DomainEvent $event)`` to attach events to your aggregate root objects.

That is all there is for simple use-cases.

If your command triggers events that listeners check for, you should:

  1. Create a domain specific event class. Use public properties to simplify.
  2. Create a event handler(s) or add method(s) to existing event handler(s).

While it seems "complicated" to create commands and events for every use-case. These objects are really dumb and only contain public properties. Using your IDE or editor functionality you can easily generate them in no time. In turn, they will make your code very explicit.

Difference between apply() and raise()

There are two ways to publish events to the outside world.

If you don't use event sourcing then you are fine just using raise() and ignoring apply() altogether.

Failing Events

The EventMessageBus prevents exceptions from bubbling up. To allow some debugging of failed event handler execution there is a special event "EventExecutionFailed" that you can listen to. You will get passed an instance of Glow\Bus\EventExecutionFailed with properties $exception, $service and $event to allow analysing failures in your application.

Extension Points

You should implement your own CommandBus or extend the existing to wire the whole process together exactly as you need it to work.

Plugins

Symfony

Inside symfony you can use Glow by registering services with lite_cqrs.command_handler or the lite_cqrs.event_handler tag. These services are then autodiscovered for commands and events.

Command- and Event-Handlers are lazily loaded from the Symfony Dependency Injection Container.

To enable the bundle put the following in your Kernel:

You can enable/disable the bundle by adding the following to your config.yml:

lite_cqrs: ~

Please refer to the SymfonyExample.md document for a full demonstration of using Glow from within a Symfony2 project.

Monolog

A plugin that logs the execution of every command and handler using Monolog. It includes the type and name of the message, its parameters as json and if its execution succeeded or failed.

The Monolog integration into Symfony registers a specific channel lite_cqrs which you can configure differently from the default channels in Symfony. See the Symfony cookbook for more information.


All versions of glow with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ramsey/uuid Version ^3.6
roave/security-advisories Version dev-master
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 lidskasila/glow contains the following files

Loading the files please wait ....