PHPackages                             fproject/workflowii - 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. fproject/workflowii

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

fproject/workflowii
===================

Workflow Engine for Yii 2 Framework

0.5.0(10y ago)662[2 issues](https://github.com/fproject/workflowii/issues)Apache License 2.0PHPPHP &gt;=5.4.0

Since May 18Pushed 10y ago4 watchersCompare

[ Source](https://github.com/fproject/workflowii)[ Packagist](https://packagist.org/packages/fproject/workflowii)[ Docs](https://github.com/fproject/workflowii)[ RSS](/packages/fproject-workflowii/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (13)Used By (0)

Workflow Engine for Yii 2 Framework
===================================

[](#workflow-engine-for-yii-2-framework)

[![Latest Stable Version](https://camo.githubusercontent.com/d39c8e3999b90798bd75ca0ef504db647554fe3271448f60103ab6290884d264/68747470733a2f2f706f7365722e707567782e6f72672f6670726f6a6563742f776f726b666c6f7769692f762f737461626c65)](https://packagist.org/packages/fproject/workflowii)[![Total Downloads](https://camo.githubusercontent.com/b5deb638445eebaa3febf44de3d56d2b720fa5ff2a0e351bda3fe17829352a22/68747470733a2f2f706f7365722e707567782e6f72672f6670726f6a6563742f776f726b666c6f7769692f646f776e6c6f616473)](https://packagist.org/packages/fproject/workflowii)[![Latest Unstable Version](https://camo.githubusercontent.com/e5aa1494e2a98876d4cf067ec28ef97c788f8715ae75e39b83e6b87c52c5eb59/68747470733a2f2f706f7365722e707567782e6f72672f6670726f6a6563742f776f726b666c6f7769692f762f756e737461626c65)](https://packagist.org/packages/fproject/workflowii)[![Build](https://camo.githubusercontent.com/270b8ee45737c605507d0786572360a4ab9a2636539fcf13d9156914f350eee1/68747470733a2f2f7472617669732d63692e6f72672f6670726f6a6563742f776f726b666c6f7769692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/fproject/workflowii)[![License](https://camo.githubusercontent.com/df586aa8a98b99371a4f3585284b50a206e9f1318a7635bdcdf75049571ae1ce/68747470733a2f2f706f7365722e707567782e6f72672f6670726f6a6563742f776f726b666c6f7769692f6c6963656e7365)](https://packagist.org/packages/fproject/workflowii)

INSTALLATION
------------

[](#installation)

The preferred way to install **Workflowii** is through [composer](http://getcomposer.org/download/).

You can either run:

```
php composer.phar require fproject/workflowii "*"

```

or add this block to the *require* section of your `composer.json` file:

```
"require" : {
		"php" : ">=5.4.0",
		"yiisoft/yii2" : "*",
		"fproject/workflowii": "*",
		// ...
	}
```

REQUIREMENTS
------------

[](#requirements)

The minimum requirement by Workflowii:

- Your Web server supports PHP 5.4 or above
- Your Web server is running on Yii 2.0.0 or above

QUICK START
-----------

[](#quick-start)

### Configuration

[](#configuration)

In this simple start guide we use default configuration settings, but note that *workflowii* is designed to be highly flexible so to adapt to a lot of execution contexts.

### Create A WorkflowSource

[](#create-a-workflowsource)

A workflow source is defined as a PHP class that implements the `\fproject\workflow\core\IWorkflowSource` interface. This interface declares the *getDefinition()* method that must return an array representing the workflow of a model object.

Let's define a very simple workflow source that will be used to manage article posts represented by `Article` model class. This workflow source will simply return the same workflow for all model object instances of `Article`, by specifying a PHP associative array as return value of `getDefinition()` method:

*ArticleWorkflowSource.php*

```
class ArticleWorkflowSource implements \fproject\workflow\core\IWorkflowSource
{
	public function getDefinition($model) {
		return [
			'initialStatusId' => 'draft',
			'status' => [
				'draft' => [
					'transition' => ['published','deleted']
				],
				'published' => [
					'transition' => ['draft','deleted']
				],
				'deleted' => [
					'transition' => ['draft']
				]
			]
		];
	}
}
```

### Attach ActiveWorkflowBehavior To The Model

[](#attach-activeworkflowbehavior-to-the-model)

Now let's have a look to our `Article` model that extends from \\yii\\db\\ActiveRecord and has a column named `status` of type `string`.

The last step is to associate the workflow definition with articles models. All things we have to do is overriding the `function behaviors()` method in the `Article` model class and specify the *ActiveWorkflowBehavior* behavior as return value. That's all, the *workflowii*'s default configuration settings will do the rest for you.

*Article.php*

```
/**
 * @property integer $id
 * @property string $title
 * @property string $body
 * @property string $status column used to store the status of the article
 */
class Article extends \yii\db\ActiveRecord
{
    public function behaviors()
    {
    	return [
			\fproject\workflow\core\ActiveWorkflowBehavior::className()
    	];
    }
    // ...
```

By default, the `ActiveWorkflowBehavior` will search to find a workflow source class that has the same namespace with the model class and has the class name is the model class name with suffix `WorkflowSource`. In this case, it will be `ArticleWorkflowSource`.

Thus, we are now ready to play with `ArticleWorkflowSource` workflow that dedicated for `Article` model.

### Let's Use It !

[](#lets-use-it-)

Now that we are all setup, we can use the *ActiveWorkflowBehavior* methods to set/get the status of our articles : the *ActiveWorkflowBehavior* will take care that the article doesn't reach a status where it is not supposed to go, depending on the workflow definition that we have created.

```
$article = new Article();
$article->status = 'draft';
$article->save();
echo 'article status now is : '. $article->workflowStatus->label;
```

This will print the following message :

```
article status is : Draft

```

If you do the same thing but instead of *draft* set the status to *published* and try to save it, the following exception is thrown :

```
Not an initial status : ArticleWorkflow/published ("ArticleWorkflow/draft" expected)

```

That's because in your workflow definition the **initial status** is set to *draft* and not *published*.

Now we will go further. This time we are not going to perform the transition when the Article is saved (like we did in the previous example), but immediately by invoking the `sendToStatus` method. Our Article is going to try to reach status *published* passing through *deleted*which is strictly forbidden by the workflow. Will it be successful in this risky attempt of breaking workflow rules ?

```
$article = new Article();
$article->sendToStatus('draft'); // OK
$article->sendToStatus('deleted'); // OK
$article->sendToStatus('published'); // Error!
```

There is no transition between *deleted* and *published*, and that's what *Workflow* tries to explain the problem:

```
Workflow Exception – fproject\workflow\core\WorkflowException
No transition found between status ArticleWorkflow/deleted and ArticleWorkflow/published

```

Yes, that's severe, but there was many ways to avoid this exception like for instance by first validating that the transition was possible.

### What's Next ?

[](#whats-next-)

This is just a very simple way of using the *ActiveWorkflowBehavior*. Workflowii has much more functionalities enough to assist you in your workflow management inside your Yii 2 web app.

In the meantime you can have a look to the [Workflowii User Guide](guide) (still under dev) and send any feedback.

\##ROADMAP

- At the first stage, we build a workflow engine based on Yii 2 Framework with basic functionalities.
- At the second stage, we are planning to develop a web component that allows users display/edit workflows by interacting with a RIA GUI, using HTML5 or Flex.

\##LICENSE

**Workflowii** is released under the Apache 2.0 License. See the bundled `LICENSE.md` for details.

\##LINKS

- [GitHub](https://github.com/fproject/workflowii)
- [Packagist](https://packagist.org/packages/fproject/workflowii)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~21 days

Recently: every ~39 days

Total

12

Last Release

3782d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b46aa1d9b38769bf891a8a11893d63528bb5c5fd9e3a41d5604152053e7dfee1?d=identicon)[F-Project](/maintainers/F-Project)

---

Top Contributors

[![h3d-thanhpv](https://avatars.githubusercontent.com/u/6016904?v=4)](https://github.com/h3d-thanhpv "h3d-thanhpv (1 commits)")

---

Tags

workflowyii2workflow engine

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/fproject-workflowii/health.svg)

```
[![Health](https://phpackages.com/badges/fproject-workflowii/health.svg)](https://phpackages.com/packages/fproject-workflowii)
```

###  Alternatives

[raoul2000/yii2-workflow

A simple workflow engine for Yii2

17289.8k32](/packages/raoul2000-yii2-workflow)[yiisoft/yii2-twig

The Twig integration for the Yii framework

1431.9M32](/packages/yiisoft-yii2-twig)[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k47](/packages/skeeks-cms)[cornernote/yii2-workflow-manager

Workflow Manager for Yii2.

3736.1k26](/packages/cornernote-yii2-workflow-manager)[tecnocen/yii2-workflow

Yii 2 Library to configure workflows

136.2k](/packages/tecnocen-yii2-workflow)

PHPackages © 2026

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