Download the PHP package smskin/laravel-saga without Composer

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

State Machine Engine for Laravel Projects

Composer Static Analysis Tests

While working with .Net Core and MassTransit, it became frustrating that Laravel lacked a ready-made state machine engine. Inspired by MassTransit, I wrote a library that functions similarly to MassTransit sagas.

Installation

Configuration

In the configuration file , you will find the engine settings and descriptions of state machines.

Saga Structure

Let's examine a saga from an example in this library ().

Property $context

This property describes the type (cast) of the stored object of the state machine. It can be any class inheriting from SagaContext. This object allows storing intermediate values obtained during interaction with other services during operation.

Method setup()

This method describes the state machine's operation algorithm.

Three key blocks of a saga:

Correlation

This block describes the algorithm for obtaining the identifier of the state machine's context in the repository. It's described using two methods:

This block can be read as: Upon receiving the EUserCreated event, take the state machine's ID from the property.

This block can be read as: Upon receiving the EUserBlocked event, find the state machine by the field, taking the value from the event. Thus, the engine can search for the state machine's context both by UUID and by any context field.

Initialization Event\Command

This block describes the events\commands that will initialize the state machine.

The method takes two arguments:

This block can be read as:

State Machine Transition Logic

This block describes the state machine's algorithm. Key phrases:

This block can be read as:

This block can be read as:

This block can be read as:

Basic Operation Principle

The engine operates based on the Laravel Events. The events described in the method are registered in the EventServiceProvider. The saga acts as a Listener.

When an event enters the bus, the Laravel broker executes the method of the sagas registered for that event.

Execution Optimization

Since the events to which the saga registers are described within the saga itself, Laravel will require time to compute these events from all sagas. To optimize this, an artisan command is written that saves a pre-computed cache of event=saga mapping ready for registration.

Caching

Cache Clearing

Configuration Options

Changing the Saga Data Storage Repository

  1. Create a class implementing the interface.
  2. Add it to the configuration.
  3. Specify it in the configuration variable.

Changing the Logger

  1. Create a class implementing the interface.
  2. Specify it in the configuration.

Creating Custom Sagas

  1. Create a class inheriting from .
  2. Describe the logic of the state machine in the method.
  3. Specify the class in the configuration.

All versions of laravel-saga with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version ^10 || ^11
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 smskin/laravel-saga contains the following files

Loading the files please wait ....