Download the PHP package louishrg/state-flow without Composer

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

Laravel State Flow

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Simple state machine / resilient states for your Laravel application!

Installation

You can install the package via composer:

Create your states classes with artisan :

Creating files for every available states is repetitive, that's why this package provide an artisan command to speed up the process :

Simple states AKA Stack

A Stack is a simple state machine that doesn't need to register transitions. It's a very convenient way to add a hardcoded type or category to your model.

How to use :

You need at least 1 variable: key which is the real value of the column in the database.

If you want to use other variables as key, you can give the name of the variable in you stateStack creation (see below)

Declare your states classes in the directory of your choice, for example :

Now, add all the needed declaration in your model :

Now you can get your state like so :

If you want to update/create an object with a state:

Laravel Nova:

If you want to use the package in nova, you should use it as following :

Example with a select:

Useful Methods :

If you want to compare the current value of a state with another one, you can use

Also, you can directly get the class of your current state :

If you want to retrieve all your states registered in a namespace as a collection :

Complex States AKA Flow:

If you want to use the real state machine pattern in your app you can add register like so:

Methods for flows :

When using flows, you can check if you can transition to another state like so :

Or you can get all the possible transitions for your current state :

Magic methods for your state :

When you are retrieving rows from your database, you new to instanciate your state to get the key :

In order to simplify the syntax, every State values extend a StateAbstract that provide magic methods :

The magic methods can get you every property defined in your State

Features to come:

Testing

Changelog

Please see CHANGELOG for more information about what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.


All versions of state-flow with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2|^8.1
laravel/framework Version ^7.2|^8.0|^9.0|^10.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 louishrg/state-flow contains the following files

Loading the files please wait ....