Getting Started
cakephp-workflow is a CakePHP plugin for state-machine style workflows.
What It Does
The plugin tracks where records are in their lifecycle:
- An order:
pending→paid→shipped→completed - A ticket:
open→in_progress→resolved - An approval:
draft→submitted→approved
At any moment, a record is in exactly one state. You control how it moves between states.
Core Features
| Feature | Description |
|---|---|
| PHP 8 Attributes | Define workflows in PHP classes |
| NEON/YAML | Or use config files |
| Guards | Conditional transitions |
| Commands | Actions on transitions |
| ORM Behavior | CakePHP table integration |
| Admin UI | Visual dashboard |
| CLI Tools | Management commands |
Typical Flow
1. Define a workflow (attributes or config file)
2. Attach behavior to your table
3. Use workflow.can() and workflow.apply()
4. Inspect via admin UI or CLIWhat It Is Good For
- Clear lifecycle for records (orders, tickets, payouts, approvals)
- CakePHP ORM integration through a behavior
- PHP-first definitions with editor support
- Workflow inspection from an admin dashboard
What It Is Not
This is a single-state workflow engine:
- An entity is in one state at a time
- Transitions move from one state to one target state
- It is not a multi-place workflow-net engine
For most application lifecycles, this is exactly the right level of complexity.
Quick Example
php
$orders = $this->fetchTable('Orders');
$order = $orders->get($id);
$result = $orders->getBehavior('Workflow')->transition($order, 'pay');
if ($result->isSuccess()) {
$this->Flash->success('Payment recorded.');
}Next Steps
- Installation - Get the plugin running
- Concepts - Understand states, transitions, guards
- Getting started - Build your first workflow
- Behavior Integration - Full API reference