PHPackages                             msnisha/laraflow - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. msnisha/laraflow

ActiveLibrary

msnisha/laraflow
================

Laravel workflow package for Eloquent models.

v0.16(7y ago)012MITPHPPHP ^5.6.4 || ^7.0

Since Jul 18Pushed 7y ago1 watchersCompare

[ Source](https://github.com/msnisha/laraflow)[ Packagist](https://packagist.org/packages/msnisha/laraflow)[ RSS](/packages/msnisha-laraflow/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

Forked to change the Laravel Version Supported hoping to bring more features to this

Laraflow Workflow Package
=========================

[](#laraflow-workflow-package)

Laraflow is a standard workflow package for Laravel Eloquent objects. You can define your steps, the transition between the them, callbacks, and validators.

[![StyleCI](https://camo.githubusercontent.com/ea82c911556e3991ae8cb207951aa952581a0ee9975c17da67acae88c425cf34/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3134313239353532392f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/141295529)

### Installation (via composer)

[](#installation-via-composer)

You can install the package via composer. The package require Laravel 5.5 or higher

```
composer require msnisha/Laraflow
```

You need to crate the necessary table for the historical data:

```
php artisan migrate
```

After Laravel 5.5 you don't need to manually add the service provider to the config/app.php.

#### Configuration array

[](#configuration-array)

You need a configuration array before you use the Laraflow workflow. For example:

```
[
    'property_path' => 'last_step',
    'steps' => [
        [
            'text' => 'Open',
            'extra' => []
        ],
        [
            'text' => 'In Progress',
            'extra' => []
        ],
        [
            'text' => 'Resolved',
            'extra' => []
        ],
        [
            'text' => 'Reopen',
            'extra' => []
        ],
        [
            'text' => 'Closed',
            'extra' => []
        ],
    ],
    'transitions' => [
        [
            'from' =>  0,
            'to' => 1,
            'text' => 'Start Progress',
            'extra' => [],
            'callbacks' => [
                'pre' => [
                    'App\\TestPreCallback'
                ],
                'post' => [
                    'App\\TestPostCallback'
                ]
            ],
            'validators' => [
                [
                    'title' => 'numeric',
                    'assignee_id' => 'required'
                ]
            ]
        ],
        [
            'from' => 1,
            'to' => 0,
            'text' => 'Stop Progress',
            'extra' => [],
            'callbacks' => [
                'pre' => [],
                'post' => []
            ],
            'validators' => []
        ],
        [
            'from' => 1,
            'to' =>  2,
            'text' => 'Resolve Issue',
            'extra' => [],
            'callbacks' => [
                'pre' => [],
                'post' => []
            ],
            'validators' => []
        ],
        [
            'from' => 2,
            'to' =>  3,
            'text' => 'Reopen Issue',
            'extra' => [],
            'callbacks' => [
                'pre' => [],
                'post' => []
            ],
            'validators' => []
        ],
        [
            'from' => 3,
            'to' =>  2,
            'text' => 'Resolve Issue',
            'extra' => [
                'fromPort' => 'R',
                'toPort' => 'R',
                'points' => []
            ],
            'callbacks' => [
                'pre' => [],
                'post' => []
            ],
            'validators' => []
        ],
        [
            'from' => 1,
            'to' =>  4,
            'text' => 'Close Issue',
            'extra' => [],
            'callbacks' => [
                'pre' => [],
                'post' => []
            ],
            'validators' => []
        ],
        [
            'from' => 3,
            'to' =>  4,
            'text' => 'Close Issue',
            'extra' => [],
            'callbacks' => [
                'pre' => [],
                'post' => []
            ],
            'validators' => []
        ],
    ],
```

This configuration contains a sample workflow. Every step has a text which you can use to display them. All of the other necessary attributes has to be add to the extra array.
The *property\_path* contains the column name in the table which stores the actual step of the record.

Usage
-----

[](#usage)

##### Step 1

[](#step-1)

First you need to add a new column to your Eloquent model table for example called: last\_step/status or whatever you want.

```
 $table->string('last_state');
```

In your config file *property\_path* attribute has to be the same value than the column name.

##### Step 2

[](#step-2)

You have to add the *Flowable* trait to your Eloquent model to use the workflow.

```
use szana8\Laraflow\Traits\Flowable;

class SampleClass extends Model {

    use Flowable;

```

##### Step 3

[](#step-3)

Than you have to add a function to your eloquent model called *getLaraflowStates()* .
This function has to return the array of the configuration!

##### Step 4

[](#step-4)

If you want to change the status of the Eloquent object you can use the

```
$object->transiton($new_status);
$object->save();
```

method which comes from the *Flowable* trait. The *$new\_status* parameter is the value of the *key* attribute which comes from the *getPossibleTransitions()* function.

Events
------

[](#events)

You can listen to the 'global' events which fires in every status changes.

```
LaraflowEvents::PRE_TRANSITION
LaraflowEvents::POST_TRANSITION
LaraflowEvents::CAN_TRANSITION
```

The *PRE\_TRANSITION* fires before the status change, the *POST\_TRANSITION* fires after. The *CAN\_TRANSITION* fires when the package checks the transition is possible from the actual step. You can define callback(s) which will be call from the specified transition.

Validators
----------

[](#validators)

The package comes with a default validator class, which use the Laravel Validator class. You can add validation rules to the transitions, so the package can checks the Eloquent object attributes with the given rules before the transition. If the validation fails throws a LaraflowValidatorException exception with the error message(s) array.

You can define your own validator if you create a class which implements the *LaraflowValidatorInterface*.

#### Credits

[](#credits)

This library has been highly inspired by .

#### License

[](#license)

The package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Recently: every ~55 days

Total

7

Last Release

2572d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b65aa22196cfa2138203b1374352f2c8b2682e50cc7af355072b3b6d0fb049f?d=identicon)[msnisha](/maintainers/msnisha)

---

Top Contributors

[![szana8](https://avatars.githubusercontent.com/u/4242050?v=4)](https://github.com/szana8 "szana8 (17 commits)")[![msnisha](https://avatars.githubusercontent.com/u/1941380?v=4)](https://github.com/msnisha "msnisha (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/msnisha-laraflow/health.svg)

```
[![Health](https://phpackages.com/badges/msnisha-laraflow/health.svg)](https://phpackages.com/packages/msnisha-laraflow)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M685](/packages/barryvdh-laravel-ide-helper)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[dragon-code/migrate-db

Easy data transfer from one database to another

15717.4k](/packages/dragon-code-migrate-db)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
