Download the PHP package alterway/component-workflow without Composer
On this page you can find all versions of the php package alterway/component-workflow. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alterway/component-workflow
More information about alterway/component-workflow
Files in alterway/component-workflow
Package component-workflow
Short Description Workflow component heavily used by Alter Way
License
Informations about the package component-workflow
Workflow Component
This component provides a workflow engine written as a PHP library.
Instead of modeling a workflow as a Petri net or trying to enumerate workflow patterns, the library consider a workflow as a simple directed graph: vertices model nodes and edges model transitions.
Nodes
A node represents a point in a life cycle.
The Node
class implements the concept.
A node is referenced by a unique name across the workflow.
The constraint is the responsibility of NodeMap
class.
Transitions
A transition is a link between nodes.
The Transition
class implements the concept.
At creation, a transition is given a specification object implementing the SpecificationInterface
.
the specification is used as a business rule to decide where to advance in the workflow.
Tokens
A token is a simple string used to initialize the workflow in a particular node. The idea is to consider the token as a thing placed at the center of a node. When workflow engine is on, the token is moving from node to node.
Events
An event is an object created each time a token arrives at a node.
The Event
class implements the concept.
This class extends the Event
class from the Symfony EventDispatcher component.
You can write listeners or subscribers to implement any business behaviour.
Usage
Let's say you are writing a blog engine in PHP and you want to implement the following workflow:
- an article begins its existence as a draft
- when ready, the article gets published
- if controversial, the article is deleted
- when too old, the article is archived
First of all, you need to write classes implementing SpecificationInterface
for every business rule:
Then, you can use the Builder
class and the specifications to describe the workflow:
Finally, you have to listen on events dispatched by the workflow to attach the business behavior:
Contributing
Pretty please, with sugar on top, phpspec specifications are provided and should be green when contributing code.
References
Theory
PHP
- An activity based workflow engine
- eZ Workflow component
- Yii simpleWorkflow extension
- Galaxia workflow engine
- State pattern by Sebastian Bergmann
- Petrinet Framework
Licencing
See the bundled LICENSE file for details.