Skip to content

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 ​

FeatureDescription
PHP 8 AttributesDefine workflows in PHP classes
NEON/YAMLOr use config files
GuardsConditional transitions
CommandsActions on transitions
ORM BehaviorCakePHP table integration
Admin UIVisual dashboard
CLI ToolsManagement 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 CLI

What 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 ​

  1. Installation - Get the plugin running
  2. Concepts - Understand states, transitions, guards
  3. Getting started - Build your first workflow
  4. Behavior Integration - Full API reference

Released under the MIT License.