Download the PHP package juststeveking/state-machine without Composer

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

State Machine

A small, framework-agnostic PHP state machine for modeling valid transitions between states.

It is built around three contracts:

You define your own states, transitions, and domain events. The package validates transitions and throws clear exceptions when a transition is invalid.

Requirements

Installation

30-Second Quick Start

If you already have your own states and transitions, this is the smallest working flow:

How It Works

When you attempt a transition, the package checks:

  1. Is this transition class registered on the machine?
  2. Is the current state one of the transition's allowed from() states?
  3. Does the transition guard() allow it?
  4. If all pass, create and return the domain event from eventClass().

If any check fails, an InvalidTransitionException is thrown.

Quick Start

This example models publishing a blog post from draft to published.

1. Create your states

2. Create your event

3. Create a transition

4. Create a machine adapter for your model/entity

5. Run a transition

Second Example: Publish And Archive

This example shows one machine with multiple transitions and state-dependent rules.

Use this when you want to support a lifecycle like draft -> published -> archived.

Exception Messages

InvalidTransitionException includes named constructors and clear messages for:

This makes it easy to return user-friendly validation errors or audit denied actions.

Important Notes

Testing

If you are contributing to this package:

License

MIT


All versions of state-machine with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
illuminate/collections Version ^13.9
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 juststeveking/state-machine contains the following files

Loading the files please wait ...