PHPackages                             soap/laravel-workflow-process - 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. soap/laravel-workflow-process

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

soap/laravel-workflow-process
=============================

Provides Laravel workflow guards using Symfony expression and related objects

v1.0.4(1y ago)21.1k[2 PRs](https://github.com/soap/laravel-workflow-process/pulls)MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Sep 26Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/soap/laravel-workflow-process)[ Packagist](https://packagist.org/packages/soap/laravel-workflow-process)[ Docs](https://github.com/soap/laravel-workflow-process)[ GitHub Sponsors]()[ RSS](/packages/soap-laravel-workflow-process/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (15)Versions (11)Used By (0)

Provides Laravel workflow guards using Symfony expression and related objects
=============================================================================

[](#provides-laravel-workflow-guards-using-symfony-expression-and-related-objects)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2f9d7fd9b4d21e0c887da34319256531b435f07b90d1189df97fdc2c96ae120e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f61702f6c61726176656c2d776f726b666c6f772d70726f636573732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soap/laravel-workflow-process)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0c3483c2d88bbcff5b5ab4c4f7b0ed0ecdfebac8a7c6e57c880edc5933d52efb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f61702f6c61726176656c2d776f726b666c6f772d70726f636573732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/soap/laravel-workflow-process/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/d1f62acd50036d7a71ba0e241cd3346cd6b7b7c28c6358427091c679e8cf9634/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f61702f6c61726176656c2d776f726b666c6f772d70726f636573732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/soap/laravel-workflow-process/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/bd5ef5d6ce7fe4169e51cbfbba9fceb490fe93731f145c5e2999e8024983d262/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f61702f6c61726176656c2d776f726b666c6f772d70726f636573732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soap/laravel-workflow-process)

Using [Zerodahero's Laravel Workflow (based on Symfony Workflow)](https://github.com/zerodahero/laravel-workflow) to handle state-transition workflow is great. However, coding transition guards in events is hard. This package provides a simple way; you can add Symfony Expression Language as a transition guard for each transition. This configuration must be provided in transition metadata using the 'guard' key. The package subscribes for all workflows' transition guard events and uses the provided Symfony Expression Language to allow or block the transition.

Laravel vesionPackage version10.x, 11.x, 12.x1.xSupport me
----------

[](#support-me)

Any recommendation or pull request is welcome. It is great if you sponsor me if you find my work valuable.

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

[](#installation)

You can install the package via composer:

```
composer require soap/laravel-workflow-process
```

You can publish the config file with:

```
php artisan vendor:publish --tag="workflow-process-config"
```

This is the contents of the published config file:

```
return [
    'custom_functions' => [
        // 'function_name' => [
        //     'compiler'  => function () { return 'true'; },
        //     'evaluator' => function (array $variables) { return true; },
        // ],
        // 'function_name' => 'App\CustomGuardFunction',
        // 'authenicated' => \Soap\LaravelWorkflowProcess\GuardFunctions\Authenticated::class,

        'authenticated' => [
            'compiler' => function ($guard = 'web') {
                return sprintf('authenticated("%s")', $guard);
            },
            'evaluator' => function (array $variables, $guard = 'web') {
                // This allows checking a specific guard (e.g., 'web', 'api', etc.)
                return auth()->guard($guard)->check();
            },
        ],
    ],
];
```

Usage
-----

[](#usage)

Task that you have to do is providing guard configuration like the following example. This is in laravel-workflow 's configuration file (config/workflow.php). If you want to store workflow configuration in database, please visit [my Laravel Workflow Loader package](https://github.com/soap/laravel-workflow-loader).

```
// file config/workflow.php
use ZeroDaHero\LaravelWorkflow\MarkingStores\EloquentMarkingStore;

return [
    'blogPost' => [
        'type' => 'workflow',
        'supports' => [App\Models\BlogPost::class],
        'marking_store' => [
            'property' => 'state',
            'type' => 'single_state',
            'class' => EloquentMarkingStore::class,
        ],
        'places' => ['draft', 'pending_for_review', 'approved', 'rejected', 'published', 'archived'],
        'transitions' => [
            'submit' => [
                'from' => 'draft',
                'to' => 'pending_for_review',
                'metadata' => [
                    'guard' => 'authenticated and subject.isOwnedBy(user)',
                ],
            ],
            'approve' => [
                'from' => 'pending_for_review',
                'to' => 'approved',
            ],
            'reject' => [
                'from' => 'pending_for_review',
                'to' => 'rejected',
            ],
            'publish' => [
                'from' => 'approved',
                'to' => 'published',
            ],
            'archive' => [
                'from' => ['draft', 'rejected'],
                'to' => 'archived',
            ],
        ],
    ]

];
```

Currenty these variables/objects were injected into Symfony Expression Language.

- "subject" is the Eloquent model which is subject of a workflow
- "user" is authenticated user.
- "authenticated" boolean, true if user was authenticated. You can

So you can call any method on the injected object. So you can assign guard as authenticated and subject.isPaid(), where your model has method isPaid().

Add your own guard functions
----------------------------

[](#add-your-own-guard-functions)

You can add your own guard function in two way. The first one is inline in configuration file. The second way is define your GuardFunction class by implement GuardFunctionInterface and point to it in the configuration. You can see example in the provided configuration file.

You can also overide the GuardEvaluator class in Application Service Provider with your own class.

Todo
----

[](#todo)

I have a plan to provide document role for user. For example, some users may be assign as "reviewer" or "approver" for Eloquent model. So we can use something like subject.hasActorRole('reviewer') or subject.canBeReviewedBy(user). Any suggestion is welcome.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Prasit Gebsaap](https://github.com/soap)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance71

Regular maintenance activity

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 58.8% 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 ~32 days

Recently: every ~0 days

Total

7

Last Release

408d ago

Major Versions

v0.1.2 → v1.0.02025-04-04

PHP version history (3 changes)v0.1.1PHP ^8.2

v0.1.2PHP ^8.2|^8.3

v1.0.0PHP ^8.2|^8.3|^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1073690?v=4)[Prasit Gebsaap](/maintainers/soap)[@soap](https://github.com/soap)

---

Top Contributors

[![soap](https://avatars.githubusercontent.com/u/1073690?v=4)](https://github.com/soap "soap (40 commits)")[![kpscyber](https://avatars.githubusercontent.com/u/126277570?v=4)](https://github.com/kpscyber "kpscyber (13 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

symfonylaravellanguagetransitionexpressionguardprasit gebsaaplaravel-workflow-process

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/soap-laravel-workflow-process/health.svg)

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

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