Skip to content

limen/php-graflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graflow

Build Status Packagist

A simple flow controller with features

  • A flow is defined by a graph.
  • A graph is consisted of nodes and edges.
  • Edges have direction.
  • A graph can have one head node and one or multiple tail nodes.
  • A middle node is a node who is neither head node nor tail node.
  • A tail node can have one or multiple in nodes and have no out node.
  • A head node can have one or multiple out nodes and have no in node.
  • A middle node can have one or multiple in node and one or multiple out nodes.
  • The edge between two adjacent nodes could be one way or two way.

Install

Recommend to install via composer.

composer require "limen/php-graflow"

Usage

see src/Examples and tests/

Concepts

In/Out node

When node A has way to node B, A is B's in node and B is A's out node.

Contract

Define a graph in PHP array

The first key must be the head node.

[
    'blank' => ['editing', 'canceled'],
    'editing' => ['draft', 'canceled'],
    'draft' => ['editing', 'published', 'canceled'],
    'published' => ['draft', 'printed', 'canceled'],
    'printed' => [],
    'canceled' => [],
]

The equivalent graph

graph

The arrow shows the way direction.

About

A simple state flow controller

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages