PHPackages                             rhaarhoff/workflow - 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. rhaarhoff/workflow

ActiveLibrary

rhaarhoff/workflow
==================

Creates a specified workflow

v1.0.8(6y ago)623PHP

Since Mar 29Pushed 6y ago2 watchersCompare

[ Source](https://github.com/Flame1994/workflow)[ Packagist](https://packagist.org/packages/rhaarhoff/workflow)[ RSS](/packages/rhaarhoff-workflow/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (14)Used By (0)

Laravel Workflow Generator
--------------------------

[](#laravel-workflow-generator)

[![Latest Stable Version](https://camo.githubusercontent.com/458fa503d6d664e8af9686eb91cb60a1a34ed15d8c5d834bac7a3ad6cc90727f/68747470733a2f2f706f7365722e707567782e6f72672f7268616172686f66662f776f726b666c6f772f762f737461626c65)](https://packagist.org/packages/rhaarhoff/workflow)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Total Stars](https://camo.githubusercontent.com/8701ed6fef4a0251624a1f859d18e68c26c9e77302ea953b6aa838b76d2b4f90/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f466c616d65313939342f6c61726176656c2d6172746973616e2d636f6d6d616e64732e737667)](https://github.com/Flame1994/laravel-artisan-commands)[![Total Downloads](https://camo.githubusercontent.com/694338f3ee2c387b2f895f402f8eb3de0b16f7595f7a69451f16411ed0185aa9/68747470733a2f2f706f7365722e707567782e6f72672f7268616172686f66662f776f726b666c6f772f646f776e6c6f616473)](https://packagist.org/packages/rhaarhoff/workflow)

### Description

[](#description)

This package provides a way for generating workflow definitions &amp; workflows from those definitions.

For an example project on how this works visit the [workflow-example](https://github.com/Flame1994/workflow-example) github page.

### Installation

[](#installation)

Require this package with Composer using the following command:

```
composer require rhaarhoff/workflow
```

After updating Composer, add the service provider to the `providers` array in `config/app.php`:

```
Rhaarhoff\Workflow\WorkflowServiceProvider::class
```

Run the `dump-autoload` command:

```
composer dump-autoload
```

In Laravel, instead of adding the service provider in the `config/app.php` file, you can add the following code to your `app/Providers/AppServiceProvider.php` file, within the `register()` method:

```
public function register()
{
    if ($this->app->environment() !== 'production') {
        $this->app->register(\Rhaarhoff\Workflow\WorkflowServiceProvider::class);
    }
    // ...
}
```

### Commands

[](#commands)

Below you can find all the commands that you can use, including the parameters that you can specify.

```
COMMAND                     PARAMETER             DESCRIPTION
-----------------------------------------------------------------------------------------------------------------------
workflow:create                               Generates a workflow definition with the given name
workflow:create         -s       Generates a workflow definition with the given name & start state
workflow:generate                             Generates workflows for the specified workflow name in the Workflow folder
workflow:generate                                   Generates all workflows from all definitions in the Workflow folder

```

### How it works

[](#how-it-works)

A workflow is much like a state machine (see [here](https://www.techopedia.com/definition/16447/state-machine) for more information). Basically a workflow is divided into multiple 'states' or 'steps' with each step receiving an input, doing some logic, and returning an output. The ultimate goal of a workflow is to receive input, go through a defined number of steps through transitions and give an output at the end.

#### Setting up a definition file

[](#setting-up-a-definition-file)

Once you run the command to create a definition file, like `php artisan workflow:create Example` you will see something like this:

```
{
    "name": "Example",
    "uses": [],
    "namespace": "App\\Workflows\\Example",
    "startState": "start_state_function_name",
    "input": {
        "input_name": "input_type"
    },
    "output": {
        "return_name": "return_type"
    },
    "workflow": {
        "start_state_function_name": {
            "parameters": {
                "parameter_name": "parameter_type"
            },
            "result": {
                "return_value": "return_type"
            },
            "transition": {
                "function_name": ""
            }
        }
    }
}
```

What does this all mean? See the table below

```
DEFINITION PARAMETER         DESCRIPTION
----------------------------------------------------------------------------------------------
name                         The name of the workflow
uses                         The imports (use) of the workflow
namespace                    The namespace of the workflow
startState                   The function name which to start from in the workflow
input                        The list of input parameters and their type
output                       The output parameter and its type
workflow                     This is the list of workflow states / steps,
                             each listing their input parameters, result and
                             transition requirements to the next workflow state

```

In order to create a working definition file, all of the information needs to be provided within the placeholder fields. For a decent example on all capabilities of a workflow definition file, see below:

```
{
    "name": "UserUpdate",
    "uses": [
        "App\\User",
        "Common\\Id",
        "Common\\Status",
        "Common\\Contact"
    ],
    "namespace": "App\\Workflows\\UserUpdate",
    "startState": "GetExistingUserOrNull",
    "input": {
        "id": "Id",
        "name": "string|null",
        "status": "Status|null",
        "allContact": "Contact[]|null"
    },
    "output": {
        "user": "User"
    },
    "workflow": {
        "GetExistingUserOrNull": {
            "parameters": {
                "id": "Id"
            },
            "result": {
                "user": "User|null"
            },
            "transition": {
                "End": "is_null($this->user) === true",
                "ShouldUpdateUser": "is_null($this->user) === false"
            }
        },
        "ShouldUpdateUser": {
            "parameters": {
                "user": "User",
                "name": "string|null",
                "status": "Status|null",
                "allContact": "Contact[]|null"
            },
            "result": {
                "shouldUpdateUser": "bool"
            },
            "transition": {
                "End": "$this->shouldUpdateUser === false",
                "UpdateUser": "$this->shouldUpdateUser === true"
            }
        },
        "UpdateUser": {
            "parameters": {
                "user": "User",
                "name": "string|null",
                "status": "Status|null",
                "allContact": "Contact[]|null"
            },
            "result": {
                "user": "User"
            },
            "transition": {
                "End": ""
            }
        }
    }
}
```

You can see there are **three** transitions within this workflow:

- GetExistingUserOrNull is the **start state** and transitions to **ShouldUpdateUser** only if the condition specified is met, otherwise it transitions to **End**.
- ShouldUpdateUser transitions to **UpdateUser** only if the condition is met, otherwise transitions to **End**.
- UpdateUser only transitions to **End** with no condition specified.

Additional information on workflow states:

- Each workflow state takes **zero or more parameters as input** and can only specify **one output**.
- Make sure the **startState** specified, is the **first** workflow state you define.
- For every workflow transition condition, make sure to use `$this->` when referencing a variable.
- Make sure for every variable you define in the workflow, that an **import/use** is specified.
- You can't define a circular transition. (state1 -&gt; state2 -&gt; state3 -&gt; state1)
- The use of the following primitive types are allowed:
    - string
    - bool
    - integer
    - float

When you have finished setting up your definition files, run the following command to generate the code:

```
php artisan workflow:generate

```

A base **Workflow** class will be generated that all other workflow's extend from.

For each definition file, it will generate a **Base Class** as well as a class that **Extends** the base class. Your file structure for a working definition file should then look something like this:

```
Workflows
  - Common
    - Workflow.php                      // This is the base workflow class that all base workflows extend from.
  - UserUpdate
    - Code
      - WorkflowUserUpdate.php          // The workflow class where your business logic will go. This extends the base class
    - Definition
      - UserUpdate.json                 // Definition file where you define everything
    - Generated
      - WorkflowUserUpdateBase.php      // The auto generated base class that extends Workflow.php
  - ...

```

### License

[](#license)

The Laravel Workflow generator is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

9

Last Release

2220d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/43560ced6e5694b98c0bfa612425466e133639c106ebb8170cd839955cea1034?d=identicon)[rhaarhoff](/maintainers/rhaarhoff)

---

Top Contributors

[![Flame1994](https://avatars.githubusercontent.com/u/11166582?v=4)](https://github.com/Flame1994 "Flame1994 (33 commits)")

### Embed Badge

![Health badge](/badges/rhaarhoff-workflow/health.svg)

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

PHPackages © 2026

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