softius/phlow

A framework agnostic PHP library to build and execute workflows

v0.4.0 2018-07-24 06:20 UTC

This package is auto-updated.

Last update: 2024-05-14 04:20:46 UTC


README

Latest Version on Packagist Software License Build Status Code Climate Code Climate

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.

A simple flowchart for troubleshooting a broken 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

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.