softius / phlow
A framework agnostic PHP library to build and execute workflows
Requires
- php: ^7.1.3
- dusank/knapsack: ^10.0
- psr/log: ^1.0
- symfony/expression-language: ^4.1
Requires (Dev)
- phpunit/phpunit: ^6.5
- squizlabs/php_codesniffer: ^3.3
This package is auto-updated.
Last update: 2024-12-14 05:34:38 UTC
README
Phlow is a workflow modeller and engine for PHP. Heavily inspired by BPMN 2.0 and Apache Camel, Phlow attempts to provide a library to design and implement business processes in PHP projects. It utilises the notion of workflow to model a process of any kind, through which a piece of work passes from initiation to completion.
Phlow process models can be created using PHP. No third party tools are required to model and/or execute your process.
Phlow is a framework agnostic solution.
Features
✅ Sequence flow
✅ Conditional flow
✅ Error handling
✅ Callbacks
✅ Boolean expressions for Conditions
✅ PSR/3 Logger integration
✅ Execution path replay
✅ Workflow model in plain/text format
✅ Execution path in plain/text format
See the Roadmap for more information about the upcoming releases.
Getting Started
The following image illustrates a simple process for dealing with a non-functioning lamp. Once a non-functioning lamp is found, the flow evaluates whether the lamp is plugged in. If not, it evaluates whether the lamp has been burned out. In any case, particular actions must be taken i.e. replace the lamp.
Also, the following code illustrates the model for the same process.
$builder = new WorkflowBuilder(); $builder ->start() ->choice() ->when('isPluggedIn') ->callback() // Plug in lamp ->when('isBurnedOut') ->callback() // Replace lamp ->otherwise() ->callback() // Repair lamp ->endAll()
Once the model bas been built, it can be executed by creating a new instance. At this point it is possible to pass some data that could be made available throughout the process. The data can be any object which could be also updated as part of the process.
$workflow = $builder->getWorkflow(); $instance = new WorkflowInstance($workflow, $data); $instance->execute();
Installation
Phlow can be installed to your PHP project by executing the following composer command. Please note that currently there is no stable version yet available.
$ composer require softius/phlow 0.4.0
Documentation
- Overview
- Workflow Model
- Workflow Engine
- Workflow Builder
- Sequence Flow - Example
- Conditional Flow - Example
- FAQs
Testing
$ composer test
Security
If you discover any security related issues, please email softius@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.