Download the PHP package szykra/state-machine without Composer

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

Finite State Machine

Finite State Machine implementation in PHP

Installation

Install via composer

Add dependency to your composer.json file and run composer update.

or just run

Usage

Prepare your entity to be stateful

Your entity should implements interface StatefulInterface. It requires two new methods

Of course you should add new property named e.g. state.

Configure a StateMachine by adding States and Transitions

To control your entity by StateMachine you have to define:

State

State object simply represents a state. It has name and list of available transitions.

Transition

Transition is like single action which someone performs on an object. It means transition from one state to another state.

Each state has own transitions so available transitions depend on the current state of object.

StateMachine

StateMachine is a controller used to change state of stateful object. First you should create a StateMachine object and set up it by adding a valid States.

Initialize a State Machine

When your StateMachine is ready you could initialize it by Stateful Object.

Now you could change state of $document by $stateMachine. To check if transition can be performed use the can($transition) method, e.g. if current state of $document is draft the results will be as follows

To change state of object you should use run($transition) method. If transition not exists TransitionNotFoundException will be thrown.

If you want to see a complete example please see tests/ directory.

To do

License

The MIT License. Copyright © 2015 by Szymon Krajewski


All versions of state-machine with dependencies

PHP Build Version
Package Version
No informations.
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 szykra/state-machine contains the following files

Loading the files please wait ....