PHPackages                             wpstarter/flow - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. wpstarter/flow

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wpstarter/flow
==============

A library for handling workflow automation and process management seamlessly.

v1.0.9(1y ago)0405MITPHPPHP &gt;=7.4CI passing

Since Mar 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/wpstarter/flow)[ Packagist](https://packagist.org/packages/wpstarter/flow)[ RSS](/packages/wpstarter-flow/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (11)Used By (0)

WpStarter Flow
==============

[](#wpstarter-flow)

Flow package for WpStarter or Laravel framework that provides a fluent interface for handling workflow and process management.

Requirements
------------

[](#requirements)

- PHP 7.4 or higher
- WpStarter/Laravel framework
- Composer

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require wpstarter/flow
```

Configuration
-------------

[](#configuration)

You can publish the configuration file using:

```
php artisan vendor:publish --tag=flow-config
```

Usage
-----

[](#usage)

### Create Flow class extends `WpStarter\Flow\Flow`

[](#create-flow-class-extends-wpstarterflowflow)

```
namespace App\Flow\Flows;

use WpStarter\Flow\Flow;
use WpStarter\Flow\FlowRequest;
use App\Flow\Flows\OrderFlow;

class LoginFlow extends Flow{
    function handle(FlowRequest $request){
        // TODO: Implement handle() method.
        if($this->state('is_logged_in')){
            $this->redirect(OrderFlow::class);
            return ['success'=>true];
        }else{
            if(Auth::check($request['user'],$request['pass'])){
                $this->state('is_logged_in',true);
                $this->redirect(OrderFlow::class);
                return ['success'=>true];
            }else{
                return ['success'=>false,'message'=>'invalid credentials'];
            }
        }
    }
}
```

#### Flow state management

[](#flow-state-management)

Go to next flow

```
    $this->redirect(NextFlowClass::class)
```

Go to previous flow

```
    $this->back()
```

Redirect to default flow

```
    $this->redirectToDefault()
```

### Flow Providers

[](#flow-providers)

Create `App\Flow\MyFlowProvider` extends `WpStarter\Flow\Support`

```
class MyFlowProvider extends FlowProvider
{
    public function register()
    {
        $this->flows->register(LoginFlow::class);
        $this->flows->register(OrderFlow::class);
        $this->loadRoutesFrom( __DIR__ . '/routes.php');
    }
}
```

Add MyFlowProvider to `config/flow.php`

```
