PHPackages                             roaresearch/yii2-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. [Framework](/categories/framework)
4. /
5. roaresearch/yii2-workflow

ActiveYii2-extension[Framework](/categories/framework)

roaresearch/yii2-workflow
=========================

Yii 2 Library to configure workflows

2.0.2(5y ago)36231[1 PRs](https://github.com/ROAResearch/yii2-workflow/pulls)MITPHPPHP ^7.1

Since Dec 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ROAResearch/yii2-workflow)[ Packagist](https://packagist.org/packages/roaresearch/yii2-workflow)[ RSS](/packages/roaresearch-yii2-workflow/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (9)Versions (6)Used By (0)

Yii2 Workflow
=============

[](#yii2-workflow)

Library to dynamically handle workflows in a database with ROA support.

[![Latest Stable Version](https://camo.githubusercontent.com/0d07b7dc009451e0bbac7ae273d63ba0d8807b7ed7a98f8ccb93857a0bedf00d/68747470733a2f2f706f7365722e707567782e6f72672f726f6172657365617263682f796969322d776f726b666c6f772f762f737461626c65)](https://packagist.org/packages/roaresearch/yii2-workflow)[![Total Downloads](https://camo.githubusercontent.com/d64bfab3758fa778f0d0c6ae415718ce3314d1ddb39ab8db52fef8e8de3d5528/68747470733a2f2f706f7365722e707567782e6f72672f726f6172657365617263682f796969322d776f726b666c6f772f646f776e6c6f616473)](https://packagist.org/packages/roaresearch/yii2-workflow)[![Code Coverage](https://camo.githubusercontent.com/38266b56e8d73d3fc7a1c73d9330a450ca0d85b1aa7a23ed45aff11c9da4c69a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f6172657365617263682f796969322d776f726b666c6f772f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/roaresearch/yii2-workflow/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fb141f20b2fe596fb4b7fe691717612b77877b083ae4aef1d0be9416fe7be947/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f6172657365617263682f796969322d776f726b666c6f772f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/roaresearch/yii2-workflow/?branch=master)

Scrutinizer [![Build Status Scrutinizer](https://camo.githubusercontent.com/ec68100028342be9edb9e8d45e125ef2735b5899c4a19807264d7ca2b60f4a93/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f6172657365617263682f796969322d776f726b666c6f772f6261646765732f6275696c642e706e673f623d6d6173746572267374796c653d666c6174)](https://scrutinizer-ci.com/g/roaresearch/yii2-workflow/build-status/master)Travis [![Build Status Travis](https://camo.githubusercontent.com/a9ef12bfecf88a49d19f60238513a3eac21e15ae2e86b2679ff3b673c00cde8e/68747470733a2f2f7472617669732d63692e6f72672f726f6172657365617263682f796969322d776f726b666c6f772e7376673f6272616e63683d6d6173746572267374796c653d666c61743f7374796c653d666f722d7468652d6261646765)](https://travis-ci.org/roaresearch/yii2-workflow)

Getting Started
---------------

[](#getting-started)

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

### Prerequisites

[](#prerequisites)

- Install PHP 7.2 or higher
- [Composer Installed](https://getcomposer.org/doc/00-intro.md)

The rest of the requirements are checked by composer when installing the repository on the next step.

### Installation

[](#installation)

---

You can use composer to install the library `roaresearch/yii2-workflow` by running the command;

`composer require roaresearch/yii2-workflow`

or edit the `composer.json` file

```
require: {
    "roaresearch/yii2-workflow": "*",
}
```

### Deployment

[](#deployment)

Then run the required migrations

`php yii migrate/up -p=@roaresearch/workflow/migrations`

Which will install the following table structure

[![Database Diagram](diagram.png)](diagram.png)

#### ROA Backend Usage

[](#roa-backend-usage)

---

The ROA support is very simple and can be done by just adding a module version to the api container which will be used to hold the resources.

```
class Api extends \roaresearch\yii2\roa\modules\ApiContainer
{
    public $versions = [
       // other versions
       'w1' => ['class' => 'roaresearch\yii2\workflow\roa\modules\Version'],
   ];
}
```

You can then access the module to check the available resources.

- workflow
- workflow/&lt;workflow\_id:\\d+&gt;/stage
- workflow/&lt;workflow\_id:\\d+&gt;/stage/&lt;stage\_id:\\d+&gt;/transition
- workflow/&lt;workflow\_id:\\d+&gt;/stage/&lt;stage\_id:\\d+&gt;/transition/&lt;target\_id:\\d+&gt;/permission

Which will implement CRUD functionalities for a workflow.

#### Process and Worklog

[](#process-and-worklog)

---

A `process` is an entity which changes from stage depending on a workflow. Each stage change is registered on a `worklog` for each `process` record.

To create a `process` its required to create a migrations for the process and the worklog then the models to handle them, its adviced to use the provided migration templates.

```
class m170101_010101_credit extends EntityTable
{
    public function getTableName(): string
    {
        return 'credit';
    }

    public function columns(): array
    {
         return [
             'id' => $this->primaryKey(),
             'workflow_id' => $this->normalKey(),
             // other columns
         ];
    }

    public function foreignKeys(): array
    {
        return [
            'workflow_id' => ['table' => 'workflow'];
        ];
    }
}
```

```
class m170101_010102_credit_worklog extends \roaresearch\yii2\workflow\migrations\WorkLog
{
    public function getProcessTableName(): string
    {
        return 'credit';
    }
}
```

After running the migrations its necessary to create Active Record models.

```
class Credit extends \roaresearch\yii2\workflow\models\Process
{
    protected function workflowClass(): string
    {
        return CreditWorkLog::class;
    }

    public function getWorkflowId(): int
    {
        return $this->workflow_id;
    }

    public function rules()
    {
        return \yii\helpers\ArrayHelper::merge(parent::rules(), [
            // other rules here
        ]);
    }
}
```

```
class CreditWorkLog extends \roaresearch\yii2\workflow\models\WorkLog
{
    public static function processClass(): string
    {
        return Credit::class;
    }
}
```

#### Initial Worklog

[](#initial-worklog)

Notice that by default every new record of Process being validated will attempt to create an initial WorkLog. If you want to prevent this behavior for example on search models you need to set the `Process::$autogenerateInitialWorklog` to `false`

```
class CrediSearch extends \roaresearch\yii2\workflow\models\WorkLog
{
    /**
     * @inhertidoc
     */
    protected $autogenerateInitialWorklog = false;
}
```

If this option is set to `true` then on the same request which creates the process `Credit` can receive fields `comment` and `stage_id` which will be stored not in the process `Credit` but in the worklog record.

#### Relations `Process::$worklogs` and `Process::$activeWorkLog`

[](#relations-processworklogs-and-processactiveworklog)

Process models contain 2 relations to handle its work log. `$workLogs` provide the list of all the related work logs and `$activeWorkLog` find only the most recent worklog using the groupwise search strategy.

Notice that the groupwise strategy implies a join query with aliased tables, as such extra consideration is needed when joining with other queries.

#### Worklog Resource

[](#worklog-resource)

---

Each process gets a worklog about the flow of stages it goes through.

On ROA you can declare each worklog as a child resource for the process resource

```
public $resources = [
   'credit',
   'credit//worklog' => [
       'class' => WorklogResource::class,
       'modelClass' => CreditWorkLog::class,
   ]
];
```

\[Detailed documentation for worklog and its use cases\](Worklog.md\]

Running the tests
-----------------

[](#running-the-tests)

This library contains tools to set up a testing environment using composer scripts, for more information see [Testing Environment](https://github.com/roaresearch/yii2-workflow/blob/master/CONTRIBUTING.md) section.

### Break down into end to end tests

[](#break-down-into-end-to-end-tests)

Once testing environment is setup, run the following commands.

```
composer deploy-tests

```

Run tests.

```
composer run-tests

```

Run tests with coverage.

```
composer run-coverage

```

Live Demo
---------

[](#live-demo)

You can run a live demo on a freshly installed project to help you run testing or understand the responses returned by the server. The live demo is initialized with the command.

```
php -S localhost:8000 -t tests/_app

```

Where `:8000` is the port number which can be changed. This allows you call ROA services on a browser or REST client.

Use Cases
---------

[](#use-cases)

TO DO

Built With
----------

[](#built-with)

- Yii 2: The Fast, Secure and Professional PHP Framework

Code of Conduct
---------------

[](#code-of-conduct)

Please read [CODE\_OF\_CONDUCT.md](https://github.com/roaresearch/yii2-workflow/blob/master/CODE_OF_CONDUCT.md) for details on our code of conduct.

Contributing
------------

[](#contributing)

Please read [CONTRIBUTING.md](https://github.com/roaresearch/yii2-workflow/blob/master/CONTRIBUTING.md) for details on the process for submitting pull requests to us.

Versioning
----------

[](#versioning)

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/ROAResearch/yii2-roa/tags).

*Considering [SemVer](http://semver.org/) for versioning rules 9, 10 and 11 talk about pre-releases, they will not be used within the ROAResearch.*

Authors
-------

[](#authors)

- [**Angel Guevara**](https://github.com/Faryshta) - Initial work
- [**Carlos Llamosas**](https://github.com/neverabe) - Initial work

See also the list of [contributors](https://github.com/ROAResearch/yii2-roa/graphs/contributors) who participated in this project.

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~129 days

Total

3

Last Release

2079d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d5f64412ef020f8c137ff5c7f5e4a0866271f2f9ba9584e5a24aa48467f958d?d=identicon)[Faryshta](/maintainers/Faryshta)

![](https://www.gravatar.com/avatar/2341d88f3cdea0c2474cfbf59e5cf6dab5dd6a026d7846fabf219f2a93be1641?d=identicon)[neverabe](/maintainers/neverabe)

---

Top Contributors

[![Faryshta](https://avatars.githubusercontent.com/u/2029247?v=4)](https://github.com/Faryshta "Faryshta (114 commits)")[![neverabe](https://avatars.githubusercontent.com/u/1173807?v=4)](https://github.com/neverabe "neverabe (29 commits)")[![Seether69](https://avatars.githubusercontent.com/u/12069787?v=4)](https://github.com/Seether69 "Seether69 (4 commits)")[![agSoftDUCK](https://avatars.githubusercontent.com/u/59100098?v=4)](https://github.com/agSoftDUCK "agSoftDUCK (3 commits)")

---

Tags

frameworkworkflowyii2roa

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/roaresearch-yii2-workflow/health.svg)

```
[![Health](https://phpackages.com/badges/roaresearch-yii2-workflow/health.svg)](https://phpackages.com/packages/roaresearch-yii2-workflow)
```

###  Alternatives

[tecnocen/yii2-workflow

Yii 2 Library to configure workflows

136.2k](/packages/tecnocen-yii2-workflow)[yidas/yii2-bower-asset

Bower Assets for Yii 2 app provided via Composer repository

331.2M30](/packages/yidas-yii2-bower-asset)[tecnocen/yii2-formgenerator

Yii 2 Library to configure form generator

145.7k](/packages/tecnocen-yii2-formgenerator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
