Download the PHP package star/state-machine without Composer

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

PHP State machine

Build Status Scrutinizer Code Quality Code Coverage

This package help you build a workflow for a designated context, that can be encapsulated inside the given context.

It was designed to avoid having a hard dependency to the package. The library do not require you to implement any method. All the code you need to write can be encapsulated inside your context class, and it stays hidden from your other object.

Installation

composer require star/state-machine

Features

States

A state is just a name in which a context can find itself in. The state is usually kept in a persistence platform, or kept in the model using a string representation or a StateMetadata class.

Transitions

A transition is an action on the context that will move from one state to the other. A transition can only have one destination state, since there is no way for the machine to know which state to go to. On the other hand, a transition may have multiple starting states.

If no transition contains the context's current state as a start start, an exception will be raised (unless another TransitionCallback is given).

Attributes

Attributes are used to mark a state as having a meaning to the context.

Ie. Given you need a state to be considered active or closed while another state should not, you just need to add the is_active and is_closed attributes to the states that needs them.

Examples of usage

Given you have a Post context that can have the following states:

The post's allowed workflow should be as follow:

Transitions draft published archived
draft N/A publish N/A
published N/A N/A archive
archived N/A unarchive N/A

You Post class can be defined as one of the following pattern.

Using the builder in your model

Wrap the workflow in a class

If you have multiple models that can have the same workflow, defining a class that wraps the workflow can be done using the StateMetadata.

Persistence of state

The package supports the following persistence engine:

Events

The state machine has an internal event handling systems.

Multiple events are triggered at different places, which enables you to hook into the system to add behavior on certain transitions.

Subscribers that listens to these events will have their configured callback(s) called for any transitions.

Subscribing a listener in the machine

Transition callbacks

When requesting a transition, another way to hook in the process is to pass a TransitionCallback.

Transition callbacks allow to perform an action before, after or when the transition is not allowed. By default, an exception is triggered. see AlwaysThrowExceptionOnFailure.

Callback on a transition


All versions of state-machine with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
webmozart/assert Version ^1.0
symfony/event-dispatcher Version ^4.0|^5.0|^6.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 star/state-machine contains the following files

Loading the files please wait ....