workflows-for-laravel maintained by roundly-consulting
Workflows for Laravel
Versioned workflows stored as JSON graphs and run step by step on your queues: triggers, conditions, approvals, durable waits, business-time delays, escalations, retries, dry runs and templates. Your users edit a workflow in a builder; the engine runs each published version exactly as it was published.
Installation
Requires PHP 8.4, Laravel 13, and a MySQL or PostgreSQL database.
composer require roundly-consulting/workflows-for-laravel roundly-consulting/approvals-for-laravel
php artisan workflows:install
php artisan vendor:publish --tag="approvals-migrations"
php artisan migrate
Approvals powers the approval step in the example below; leave it out if you don't need approvals.
Steps run on your queue, and a step may run for up to 570 seconds, so raise the connection's
retry_after above that (DB_QUEUE_RETRY_AFTER=600 for Laravel's default database queue) —
php artisan workflows:doctor checks it.
Delays, timeouts, retries, escalations and schedules wake on the scheduler, so add one line:
// routes/console.php
use Illuminate\Support\Facades\Schedule;
Schedule::command('workflows:wake')->everyMinute()->withoutOverlapping(10)->onOneServer();
Usage
use RoundlyConsulting\Workflows\Facades\Workflows;
use RoundlyConsulting\Workflows\Graph\Build\{Party, Trigger, When};
// Once, in a service provider: what a purchase request looks like to the engine.
Workflows::subjects()->register(
Workflows::subject('purchase_request', PurchaseRequest::class)
->label('Purchase request')
->ownedBy('team')
->field('amount', 'decimal', 'Amount')
->field('requester', 'party', 'Requester')
->field('approver', 'party', 'Approver'),
);
// The workflow itself is data: a JSON graph your users edit in a builder — or written in PHP.
$definition = Workflows::definitions()->create(key: 'purchase-approval', name: 'Purchase approval',
subjectType: 'purchase_request', owner: $team);
Workflows::definition('purchase-approval', $team)->edit(Workflows::graph() // or ->edit(json_decode($json, true))
->trigger('start', Trigger::manual())
->condition('check', When::field('subject.amount')->gt('500'))
->approval('approve', approvers: [Party::field('subject.approver')])
->end('done')
->connect('start', 'check')
->connect('check', 'approve', on: 'true')
->connect('check', 'done', on: 'false')
->connect('approve', 'done', on: ['approved', 'rejected', 'expired']));
Workflows::definition('purchase-approval', $team)->publish(by: $admin);
// Start it (this graph's trigger is `manual`) — with an `event` trigger the app event starts it instead.
$result = Workflows::start('purchase-approval', subject: $request, owner: $team)
->by($request->requester)
->idempotencyKey("submit:{$request->id}")
->dispatch();
$result->instance->status; // InstanceStatus::Running — a queue worker runs it on to the approval step, where it waits
Approval, notify, transition, opening-hours and form steps light up when the matching Roundly package is installed; everything else works on its own.
Documentation
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/workflows-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
Support our work
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
License
The MIT License (MIT). See LICENSE.md.