Skip to content

What is Workflowable?

Workflowable is a flexible, event-driven workflow engine for Laravel. It lets you define complex business processes as data-driven workflow definitions stored in your database, then execute them with full audit trails, conditional branching, and retry policies.

Key Features

  • Data-driven definitions - Workflow logic is defined as JSON stored in the database, not hardcoded in PHP classes
  • Typed workflow events - Define workflow triggers as typed DTOs with constructor parameters and field-level encryption
  • Step execution - Automatic step execution with conditional transitions
  • Complete audit trail - Full execution history via Spatie event sourcing
  • Conditional branching - If/then logic to route workflows dynamically
  • Extensible step types - Register custom step types for domain-specific logic
  • Config-driven registries - Register actions and events via config
  • Retry policies - Configurable per-step retries with fixed, linear, or exponential backoff
  • CRON scheduling - Database-driven scheduled workflow triggers with duplicate prevention
  • Event-driven triggers - Laravel events auto-trigger workflows via TriggersWorkflow interface
  • Queued execution - Dispatch workflows to the queue via ExecuteWorkflowJob
  • Workflow versioning - Publish new versions while existing instances continue on their pinned version
  • Artisan commands - List, inspect, retry, schedule, and clean up workflows from the CLI
  • Testing utilities - Trait and fakes for testing workflows in your application

How It Works

Workflow Event (DTO) --> Workflow Engine --> Step Execution --> Transitions --> Completion
                              |
                              v
                        Audit Trail
  1. A WorkflowEvent DTO triggers one or more workflows bound to that event name
  2. The WorkflowEngine creates a WorkflowInstance and begins executing steps
  3. Each step is resolved by its type (action, conditional, or custom) and executed
  4. Transitions determine the next step based on the result
  5. The workflow completes or fails

Architecture Decisions

Workflowable makes deliberate architectural choices:

  • Event sourcing via Spatie for a complete, replayable audit trail with state verification
  • Data-driven definitions over code-defined workflows (definitions are portable, versionable JSON)
  • Interface-based extensibility for custom step types rather than inheritance
  • Facade pattern for a clean, Laravel-idiomatic API surface