Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Simple Task Fsm Bundle Laravel Package

evheniy/simple-task-fsm-bundle

View on GitHub
Deep Wiki
Context7

SimpleTaskFSMBundle

This bundle provides the ability to use FSM tasks runner in your application.

knpbundles.com

Latest Stable Version Total Downloads Latest Unstable Version License

Scrutinizer Code Quality Build Status

Build Status

Installation

$ composer require evheniy/simple-task-fsm-bundle "1.*"

Or add to composer.json

"evheniy/simple-task-fsm-bundle": "1.*"

AppKernel:

public function registerBundles()
{
    $bundles = array(
        ...
        new Evheniy\SimpleTaskFSMBundle\SimpleTaskFSMBundle(),
    );
    ...

Documentation

For using SimpleTaskFSMBundle you need to create state classes.

For example AppBundle/FSM/StateInit:

<?php

namespace AppBundle/FSM;

use Evheniy\SimpleTaskFSMBundle\StateAbstract;

class StateInit extends StateAbstract
{

    /**
     * @throw \Evheniy\SimpleTaskFSMBundle\Exception\StateException
     */
    public function run()
    {
        //do something...
    }
}

Then create FSM manager with this state classes (for example in Command):

use Evheniy\SimpleTaskFSMBundle\FSM;

And

$fsm = new FSM(array(new StateInit()));
foreach($fsm as $state) {
    $state->run();
}

OR

$fsm = new FSM(array(new StateInit()));
$fsm->rewind();
while($fsm->valid()) {
    $fsm->current()->run();
    $fsm->next();
}

If you have exception (You can use Evheniy\SimpleTaskFSMBundle\Exception\StateException) and You need to restart step:

$fsm = new FSM(array(new StateWithError()));

$fsm->rewind();
while($fsm->valid()) {
    try {
        $fsm->current()->run();// function run() throws StateException
        $fsm->next();
    } catch (StateException $e) {
        //do something
    }
}

You can use a lot of states and they will run one by one.

$fsm = new FSM(array(new StateInit(), new StateMainTask(), new StateFinish()));

License

This bundle is under the MIT license.

Документация на русском языке

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels