Download the PHP package dor-denis/validated-statemachine without Composer

On this page you can find all versions of the php package dor-denis/validated-statemachine. 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 validated-statemachine

Validated Statemachine for PHP

A simple statemachine with ability to validate transitions.

Usage

You can add the State Machine behavior to any PHP class by using StateMachine trait provided by this package.

You'll need to implement two methods:

State Property

If your project uses some kind of ActiveRecord approach to store models, the state value can be also persisted to the DB. To set initial state of the state machine, set default value of your property to it.

State Machine Trait

StateMachine trait offers you next methods:

For example of usage, see example/ folder

State Machine Specification

The state machine specification is basically a configuration of your state machine which lists all possible states and transitions between them.

The example is listed below

We've set state names to numbers so we could later sort them in DB by priority. You can also use strings or that.

In StateMachineSpecification class, you need to implement two methods:

Validators

You can validate your transitions by mentioning classes implementing Validator interface in key of result array.

While performing the transition, the validators are being iterated and executed. If at least one validator returns false in the method, the property of the state machine model will tell you which validator failed, and the method will return false

An example of the Validator:

The parameters passed to validator are Transition object and the state machine model.

If some params are passed to validator (like exampleParam in Validator1 in the example), they will be passed to method of the validator.

Events

The Symfony's EventDispatcher events are thrown:

To subscribe to events, use object. For more info on Symfony event dispatcher, check out it's documentation

Visualization

The HtmlVisualization class allows you to create a visualization for your state machine using the sigma.js library. It is using ForceAtlas2 algorithm to distribute the states (the nodes of the graph) and then you can drag them as you like. After that you can print the result.

State machine


All versions of validated-statemachine with dependencies

PHP Build Version
Package Version
Requires symfony/event-dispatcher Version ^4
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 dor-denis/validated-statemachine contains the following files

Loading the files please wait ....