Skip to main content

Installation

Require the package

composer require qanna-rsa/workflow-engine

The service provider and the Workflow facade alias are registered automatically via package discovery.

Publish the config

php artisan vendor:publish --tag=workflowengine::config

This writes config/workflowengine.php. See Configuration for every key.

Storage

The engine stores two things independently: workflow definitions and execution records. Each can use the file driver or the database driver, and execution records can also use an in-memory driver for tests.

File storage (default)

Nothing else to do. Definitions are written under storage_path('workflows') and execution records under storage_path('workflow/executions') as JSON. This is the zero-setup option and keeps workflow definitions diffable in git.

Database storage

Publish and run the migrations:

php artisan vendor:publish --tag=workflowengine::migrations
php artisan migrate

This creates three tables: workflows, workflow_executions, and workflow_execution_logs. Then point the drivers at the database in config/workflowengine.php (or via environment variables):

'storage' => [
'workflow' => ['driver' => env('WORKFLOW_STORAGE_DRIVER', 'database')],
'execution' => ['driver' => 'database'],
],

You can mix drivers — for example, keep definitions on file (version-controlled) while writing execution records to database (queryable at scale). See Storage.

Queue worker (for async execution)

Running a workflow with Workflow::dispatch(...), or resuming after a long Wait, uses Laravel's queue. If you use those, run a worker:

php artisan queue:work

Synchronous execution (Workflow::run(...)) needs no worker.

Scheduler (for the Schedule trigger)

The Schedule trigger registers cron entries on Laravel's scheduler at boot. For those to fire, Laravel's scheduler must be running (php artisan schedule:work locally, or the usual single cron entry calling schedule:run in production).

Webhook routes (for the Webhook trigger)

The Webhook trigger registers a POST route per workflow at boot under the webhooks/ prefix. No extra setup is required, but note that newly saved webhook/schedule/model-event workflows only wire themselves up on the next application boot — restart your app and queue workers after creating one.