PHPackages                             kitpages/workflow-bundle - 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. kitpages/workflow-bundle

ActiveSymfony-bundle[Framework](/categories/framework)

kitpages/workflow-bundle
========================

This is a Symfony2 bundle that provides a workflow system.

v1.0.0(12y ago)5541MITPHPPHP &gt;=5.3.2

Since Apr 24Pushed 10y ago6 watchersCompare

[ Source](https://github.com/kitpages/KitpagesWorkflowBundle)[ Packagist](https://packagist.org/packages/kitpages/workflow-bundle)[ Docs](https://github.com/kitpages/KitpagesWorkflowBundle)[ RSS](/packages/kitpages-workflow-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (9)Versions (3)Used By (0)

KitpagesWorkflowBundle
======================

[](#kitpagesworkflowbundle)

[![Build Status](https://camo.githubusercontent.com/b5afe09f3bf7e7f5a835a4745d0f2a490086bf83edeb2e81eb7fbfde8774985f/68747470733a2f2f7472617669732d63692e6f72672f6b697470616765732f4b69747061676573576f726b666c6f7742756e646c652e737667)](https://travis-ci.org/kitpages/KitpagesWorkflowBundle)

This bundle provides a generic workflow system.

It is used in production on a specific project, but it must be considered as an beta version.

Use case
--------

[](#use-case)

Imagine you manage (technically) 3 different newspapers : "NYC news", "Paris news" and "Grenoble news".

- For NYC news, an article has to be validated by the editor in chief only (and rewritten by the author until the editor says yes). Then it should be integrated to the printing process.
- For Paris news, an article is firstly validated by a secretary, then by a pair (another author from the same domain) and the editor. Then it should be integrated to the printing process.
- For Grenoble news : This is only an online newspaper. No validation, but it can be unpublished by the editor later

You can build a single, coherent code that can manage these 3 different buisiness processes. You can do that through a workflow system. Each newspaper process is represented by a workflow configuration file.

This bundle provides a generic workflow system build to represent any business process.

Quick start
-----------

[](#quick-start)

- add default step in config.yml

```
kitpages_workflow:
    default_step_name: workflow.default

kitpages_step:
    shared_step_list:
        workflow.default:
            help:
                short: "Default step"
                complete: |
                    This step always return default value
            class: Kitpages\WorkflowBundle\Step\DefaultStep
```

- using

```
        // create workflow configuration
        $config='
workflow_definition:
    name: hello_world
    init_state: start_state
    state_list:
        start_state:
            event_list:
                goto_end:
                    step:
                        name: workflow.default
                    next_state:
                        default: end_state
                cancel:
                    next_state: start_state
        end_state:
            event_list:
                goto_start:
                    next_state: start_state
        ';

        // get workflow manager
        $workflowManager = $this->get("workflow.manager");

        // create workflow
        $workflowConfiguration = YamlWorkflowConfigurationParser::parse($config);
        $workflow = $workflowManager->createWorkflow("hello_world_instance_workflow", $workflowConfiguration);

        // dispatch event
        $dispatcher = $this->get('event_dispatcher');
        $actionEvent = new ActionEvent("goto_end");
        $dispatcher->dispatch(KitpagesWorkflowEvents::ACTION_EVENT, $actionEvent);

        // test workflow
        $this->assertEquals ( "end_state", $workflow->getCurrentState() );

        // back to start
        $dispatcher->dispatch(KitpagesWorkflowEvents::ACTION_EVENT, new ActionEvent("goto_start"));
        $this->assertEquals ( "start_state", $workflow->getCurrentState() );
```

State of the bundle
-------------------

[](#state-of-the-bundle)

- beta state
- partially tested (60%)
- under travis-ci

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

[](#installation)

Add KitpagesWorkflowBundle in your composer.json

```
{
    "require": {
        "kitpages/workflow-bundle": "~1.0"
    }
}
```

Now tell composer to download the bundle by running:

```
$ php composer.phar update kitpages/workflow-bundle
```

AppKernel.php

```
$bundles = array(
    ...
    new Kitpages\StepBundle\KitpagesStepBundle(),
    new Kitpages\WorkflowBundle\KitpagesWorkflowBundle(),
);
```

Very minimal configuration in config.yml

```
imports:
    - { resource: @KitpagesWorkflowBundle/Resources/config/steps.yml }

kitpages_workflow:
    default_step_name: workflow.default
```

Principles
----------

[](#principles)

### General mecanism

[](#general-mecanism)

- This bundle is used to manage a state machine
- The configuration of the workflow is defined in a WorkflowConfiguration object
- The current instance of a machine state is in a Workflow object
- A workflow manager keep references of every workflow, listen for ActionEvents, run steps, change workflow states,...
- A step contains the operations to do after the reception of an ActionEvent. Then the returned value allows to decide the next workflow state according to the configuration.
- Every workflow state listen for some ActionEvent

### Everything is done in steps

[](#everything-is-done-in-steps)

Steps are classes that does something. Steps are documented in the project on github : [KitpagesStepBundle](https://github.com/kitpages/KitpagesStepBundle).

We are using steps that extends the AbstractWorkflowStep that add a reference to the current workflow and the actionEvent.

Example of step :

Configuration

```
kitpages_step:
    shared_step_list:
        my_step:
            help:
                short: "short description of my step"
                complete: |
                    Longer description
            class: Kitpages\MyBundle\Step\MyStep
            parameter_list:
                url: test.mydomain.com
            service_list:
                logger: logger
```

Code of the step

```
use Kitpages\StepBundle\Step\StepEvent;
use Kitpages\WorkflowBundle\Step\AbstractWorkflowStep;

class MyStep extends AbstractWorkflowStep {

    public function execute(StepEvent $event = null)
    {
        // get current workflow and action event
        $workflow = $this->getWorkflow();
        $actionEvent = $this->getActionEvent();

        // extract data from actionEvent
        $myValue1 = $actionEvent->get("myKey");
        $myOtherValue = $actionEvent->get("myOtherKey");

        // do someting
        $logger = $this->getService("logger");
        $logger->info("I write a log");
        $urlStepParameter = $this->getParameter("url");

        // record some values in the workflow object
        $workflow->set("resultKey", "value calculated");

        if ($someResult == true) {
            return "ok";
        } else {
            return "false";
        }
    }
}
```

More advanced Features
----------------------

[](#more-advanced-features)

TODO : features to document

- workflow parameters
- sub workflow
- workflow events and step events
- workflow configuration shortcuts
- workflow persistance
- serveral workflows in parallel

Versions
--------

[](#versions)

- 2014/04/24 : v1.0.0 - first stable release

Roadmap
-------

[](#roadmap)

Backward compatibility is maintained for version 1.x.

By 2014/06

- more tests and docs
- yaml parser in service (static call will remain but deprecated)
- pre-generation and cache for the proxy system

Later :

- a convivial debug interface

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.7% 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

Unknown

Total

1

Last Release

4404d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/95c1423b83010cc8afd1fc966d26cc6fc5d7fb5d000e5d7582adcd8392bd239c?d=identicon)[kitpages](/maintainers/kitpages)

---

Top Contributors

[![philippe-levan](https://avatars.githubusercontent.com/u/393066?v=4)](https://github.com/philippe-levan "philippe-levan (15 commits)")[![hugues-m](https://avatars.githubusercontent.com/u/5310915?v=4)](https://github.com/hugues-m "hugues-m (11 commits)")

---

Tags

workflowstep

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kitpages-workflow-bundle/health.svg)

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

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[contao/manager-bundle

Provides the Contao Managed Edition

181.3M61](/packages/contao-manager-bundle)

PHPackages © 2026

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