PHPackages                             tecnocen/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. tecnocen/yii2-workflow

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

tecnocen/yii2-workflow
======================

Yii 2 Library to configure workflows

0.4.0(6y ago)136.2k3MITPHPPHP ^7.1

Since Oct 27Pushed 6y ago8 watchersCompare

[ Source](https://github.com/tecnocen-com/yii2-workflow)[ Packagist](https://packagist.org/packages/tecnocen/yii2-workflow)[ RSS](/packages/tecnocen-yii2-workflow/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (8)Versions (7)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/528908ab69ecfceec8222bf617768e130c5d314c6dc6642d425d20810d00aa4f/68747470733a2f2f706f7365722e707567782e6f72672f7465636e6f63656e2f796969322d776f726b666c6f772f762f737461626c65)](https://packagist.org/packages/tecnocen/yii2-workflow)[![Total Downloads](https://camo.githubusercontent.com/95d93807d277bf351280203b1834421311d09508d7eed518e0613227fdf472fb/68747470733a2f2f706f7365722e707567782e6f72672f7465636e6f63656e2f796969322d776f726b666c6f772f646f776e6c6f616473)](https://packagist.org/packages/tecnocen/yii2-workflow)

Travis [![Build Status Travis](https://camo.githubusercontent.com/891ceff6da27b43b401df07a07295793f98bb7e55e907eb87ac7d085c9660458/68747470733a2f2f7472617669732d63692e6f72672f7465636e6f63656e2d636f6d2f796969322d776f726b666c6f772e7376673f6272616e63683d6d6173746572267374796c653d666c61743f7374796c653d666f722d7468652d6261646765)](https://travis-ci.org/tecnocen-com/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.1 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 `tecnocen/yii2-workflow` by running the command;

`composer require tecnocen/yii2-workflow`

or edit the `composer.json` file

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

### Deployment

[](#deployment)

Then run the required migrations

`php yii migrate/up -p=@tecnocen/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 \tecnocen\roa\modules\ApiContainer
{
    public $versions = [
       // other versions
       'w1' => ['class' => 'tecnocen\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()
    {
        return 'credit';
    }

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

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

```
class m170101_010102_credit_worklog extends \tecnocen\workflow\migrations\WorkLog
{
    public function getProcessTableName()
    {
        return 'credit';
    }
}
```

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

```
class Credit extends \tecnocen\workflow\models\Process
{
    protected function workflowClass()
    {
        return CreditWorklog::class;
    }

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

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

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

#### 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,
   ]
];
```

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/tecnocen-com/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/tecnocen-com/yii2-workflow/blob/master/CODE_OF_CONDUCT.md) for details on our code of conduct.

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

[](#contributing)

Please read [CONTRIBUTING.md](https://github.com/tecnocen-com/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/tecnocen-com/yii2-workflow/tags).

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

Authors
-------

[](#authors)

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

See also the list of [contributors](https://github.com/tecnocen-com/yii2-workflow/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

Acknowledgments
---------------

[](#acknowledgments)

- TO DO - Hat tip to anyone who's code was used
- TO DO - Inspiration
- TO DO - etc

[![yii2-workflow](https://camo.githubusercontent.com/27efd385b52d1f80968b87f3433de1f0c57983e900c12ba71c451faf51ffb62c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f77657265645f5f62792d5465636e6f63656e2e636f6d2d6f72616e67652e7376673f7374796c653d666f722d7468652d6261646765)](https://www.tecnocen.com/)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.1% 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 ~124 days

Recently: every ~139 days

Total

6

Last Release

2495d ago

PHP version history (3 changes)0.1.0PHP &gt;=5.6

0.2.0PHP ^7.1

0.3.0PHP ^7.0

### 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 (107 commits)")[![neverabe](https://avatars.githubusercontent.com/u/1173807?v=4)](https://github.com/neverabe "neverabe (26 commits)")[![Seether69](https://avatars.githubusercontent.com/u/12069787?v=4)](https://github.com/Seether69 "Seether69 (4 commits)")

---

Tags

frameworkworkflowyii2roa

### Embed Badge

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

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

###  Alternatives

[tecnocen/yii2-formgenerator

Yii 2 Library to configure form generator

145.7k](/packages/tecnocen-yii2-formgenerator)[yidas/yii2-bower-asset

Bower Assets for Yii 2 app provided via Composer repository

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

PHPackages © 2026

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