PHPackages                             dereuromark/cakephp-workflow - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. dereuromark/cakephp-workflow

ActiveCakephp-plugin[Admin Panels](/categories/admin)

dereuromark/cakephp-workflow
============================

State machine and workflow engine for CakePHP with PHP 8 Attributes, YAML support, and admin UI

0.2.1(1mo ago)21.5k↑58.9%MITPHPPHP &gt;=8.2CI passing

Since Mar 30Pushed 2w agoCompare

[ Source](https://github.com/dereuromark/cakephp-workflow)[ Packagist](https://packagist.org/packages/dereuromark/cakephp-workflow)[ Docs](https://dereuromark.github.io/cakephp-workflow/)[ RSS](/packages/dereuromark-cakephp-workflow/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (7)Dependencies (14)Versions (43)Used By (0)

CakePHP Workflow Plugin
=======================

[](#cakephp-workflow-plugin)

[![CI](https://github.com/dereuromark/cakephp-workflow/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/dereuromark/cakephp-workflow/actions/workflows/ci.yml?query=branch%3Amaster)[![codecov](https://camo.githubusercontent.com/2c2d6fe1e56a2ad87762983221ad7644e621bff7accd43e6d9c492bfa0379e96/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6465726575726f6d61726b2f63616b657068702d776f726b666c6f772f6d61737465722e737667)](https://codecov.io/gh/dereuromark/cakephp-workflow)[![Latest Stable Version](https://camo.githubusercontent.com/215f3aee2edc92c8ebc8c81527c7efc18dd9183eae260ed17a9f266f61055e60/68747470733a2f2f706f7365722e707567782e6f72672f6465726575726f6d61726b2f63616b657068702d776f726b666c6f772f762f737461626c652e737667)](https://packagist.org/packages/dereuromark/cakephp-workflow)[![Minimum PHP Version](https://camo.githubusercontent.com/ec21f169d70b69344c67d6f18fa1a24d20476d2f0cd680e8c4a1534c22f34e5f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e322d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/3add1f7abc43aa4e02e27c97cea9dd69a018a91b41ff87e458642ccca35ef85b/68747470733a2f2f706f7365722e707567782e6f72672f6465726575726f6d61726b2f63616b657068702d776f726b666c6f772f6c6963656e73652e737667)](LICENSE)[![Coding Standards](https://camo.githubusercontent.com/7d06840986f78de39fb7ba7052db7208fb349427094ac1a4540449ca87776aff/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f63732d506870436f6c6c6563746976652d707572706c652e7376673f7374796c653d666c61742d737175617265)](https://github.com/php-collective/code-sniffer)

This branch is for **CakePHP 5.2+**. See [version map](https://github.com/dereuromark/cakephp-workflow/wiki#cakephp-version-map) for details.

State machine and workflow engine for CakePHP with PHP 8 Attributes, YAML/NEON config support, and admin UI.

Tip

Try the live demo:

There is also a [demo app](https://github.com/dereuromark/cakephp-workflow-demo) with more details to experiment with

Requirements
------------

[](#requirements)

- CakePHP 5.2+

Installation
------------

[](#installation)

```
composer require dereuromark/cakephp-workflow
```

For server-side diagram exports via `/workflow/workflows/draw` in `svg` / `png`formats, install GraphViz and make sure the `dot` binary is available on the host. Widget exports in app pages do not require GraphViz.

Load the plugin:

```
bin/cake plugin load Workflow
```

Run migrations:

```
bin/cake migrations migrate --plugin Workflow
```

The generic `foreign_key` column is polymorphic and defaults to `integer`; set the shared `Polymorphic.type` key to `biginteger` for large-id apps, or `uuid` / `binaryuuid` for non-integer keys. **UUID / char primary keys are fully supported** — no code changes needed. See [Installation: Entity id type](https://dereuromark.github.io/cakephp-workflow/guide/installation#using-uuid-char-primary-keys).

Configuration
-------------

[](#configuration)

Configure the plugin in your `config/app.php`:

```
'Workflow' => [
    'adminAccess' => function (\Cake\Http\ServerRequest $request): bool {
        $identity = $request->getAttribute('identity');

        return $identity !== null && in_array('admin', (array)$identity->roles, true);
    },
    'loader' => [
        'namespaces' => [
            'App\\Workflow',
        ],
        'configPath' => CONFIG . 'workflows' . DS,
    ],
    'logging' => true,
    'locking' => true,
    'timeouts' => true,
    'lockDuration' => 30,
    'adminBackUrl' => ['plugin' => false, 'controller' => 'Dashboard', 'action' => 'index'],
    'adminActorResolver' => function (string $userId, ?\Workflow\Model\Entity\WorkflowTransition $transition = null): string {
        return 'Admin #' . $userId;
    },
],
```

The admin UI is fail-closed by default: you must provide `Workflow.adminAccess`to expose `/admin/workflow/...`. Manual admin actions also record actor and context metadata; when you still rely on legacy session auth, the admin logger falls back to `Auth.User.id` automatically.

Defining Workflows
------------------

[](#defining-workflows)

### Using PHP 8 Attributes (Recommended)

[](#using-php-8-attributes-recommended)

Create state classes in your namespace:

```
