Download the PHP package pwm/s-flow without Composer

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

S-Flow

Build Status codecov Maintainability Test Coverage License: MIT

S-Flow is a lightweight library for defining finite state machines (FSM). Once defined the machine can be run by giving it a start state and a sequence of events to derive some end state. One of the main design goals of S-Flow was to be able to define FSMs declaratively as a single top level definition. This makes the structure of the underlying graph clear and explicit which in turn helps with understanding and maintenance. S-Flow can be used for many things, eg. to define workflows or to build event sourced systems.

Table of Contents

Why

If you ever named a variable, object property or database field "status" or "state" then read on...

Claim #1:

Much grief in software development arises from our inability to control state.

Evidence:

Q: What do we do when our code breaks?

A: We debug it.

Q: What does debugging mean?

A: Observing our program's internal state trying to figure out where it went wrong.

Claim #2:

If we could better control state in our programs we would have less bugs and as a result we would spend less time debugging.

S-Flow can help controlling state by making it easy to build state machines.

Requirements

PHP 7.2+

Installation

$ composer require pwm/s-flow

Usage

There is a fully worked example under tests/unit/ShoppingCart that simulates the process of purchasing items from an imaginary shop. Below is the definition of the FSM from it:

How it works

A state machine is defined as a directed graph. Vertices of this graph are called states and arrows between them are called transitions. Transitions are labelled so that they can be identified. We call those labels events.

Running the machine, ie. deriving an end state given a start state and a sequence of events, means walking the graph from the start state via a sequence of transitions leading to the desired end state. In the end we either reach it or stop when there is no way forward.

Transitions, acting as the arrows of the graph, are functions of type (State, Event) -> State. They are uniquely identified by a (StateName, EventName) pair, ie. given a state name and an event name (which is the label of the arrow) we can get the corresponding transition function, if it exists. The the absence of the transition function automatically results in a failed transition, keeping the current state.

Success and failure is captured using the TransitionOp type. It also keeps track of the current state as well as the sequence of events leading up to it.

Tests

$ composer phpunit
$ composer phpcs
$ composer phpstan
$ composer psalm
$ composer infection

Todo

Once return type covariance lands in PHP (as part of this RFC) we will be able to specify the actual return type of __invoke in Transition implementations. This would enable to easily dump the FSM into various text formats, eg. as a DOT file, etc...

Changelog

Click here

Licence

MIT


All versions of s-flow with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 pwm/s-flow contains the following files

Loading the files please wait ....