2017 © Pedro Peláez
 

library phpflo-fbp

fbp implementation for php

image

phpflo/phpflo-fbp

fbp implementation for php

  • Tuesday, April 18, 2017
  • by asm
  • Repository
  • 1 Watchers
  • 1 Stars
  • 2,584 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 8 Versions
  • 13 % Grown

The README.md

[READONLY] phpflo-fbp: load, parse, dump

Flowbased programming protocol (FBP) config file loader, using the FBP domain specific language (DSL)., (*1)

Build Status Scrutinizer Code Quality Code Coverage License, (*2)

Introduction

This library allows you to load and parse configuration for your phpflo project. It also works standalone if you want to convert your old JSON configs to FBP spec. Supported config formats are JSON (.json), YAML (.yml) and FBP (.fbp), output is an object of type FbpDefinition. This allows you to output your parsed content in different formats, ranging from array over FBP, JSON to YAML., (*3)

Code Samples

Basic usage:, (*4)

// load FBP config
$defintiion = PhpFlo\Loader\Loader::load('my/fbp/config/file.fbp');

You can load JSON, YAML and FBP that way., (*5)

Parser by itself:, (*6)

$myFbpConfig = <<<EOF
# Read a file and cout its lines
'test.file' -> IN ReadFile(ReadFile)
ReadFile(ReadFile) OUT -> IN SplitbyLines(SplitStr)
ReadFile() ERROR -> IN Display(Output)
SplitbyLines() OUT -> IN CountLines(Counter)
CountLines() COUNT -> IN Display()
EOF;

$parser = new PhpFlo\Fbp\FbpParser();
$definition = $parser->run($myFbpConfig);

Dump your flow to a format:, (*7)

$json = PhpFlo\Fbp\FbpDumper::toJson($definition);
$yaml = PhpFlo\Fbp\FbpDumper::toYaml($definition);
$fbp = PhpFlo\Fbp\FbpDumper::toFbp($definition);

The definition has following schema:, (*8)

$schema = [
    'properties' => ['name' => '',],
    'initializers' => [
        [
            'data' => '',
            'tgt' => [
                'process' => '',
                'port' => '',
            ],
        ],
    ],
    'processes' => [
        'ReadFile' => [
            'component' => '',
            'metadata' => [
                'label' => '',
            ],
        ],
    ],
    'connections' => [
        [
            'src' => [
                'process' => '',
                'port' => '',
            ],
            'tgt' => [
                'process' => '',
                'port' => '',
            ],
        ],
    ],
]

FBP DSL defintions

If you want to write definition files, here are the rules:, (*9)

General syntax:, (*10)

// <process_alias>(<optional_process_name>) <port><[optional_port_number]> -> <port><[optional_port_number]> <process_alias>(<optional_process_name>)
// examples
ReadFile(ReadFile) OUT -> IN SplitbyLines(SplitStr)
ReadFile() OUT -> IN SplitbyLines()
ReadFile() out[1] -> In[3] SplitbyLines()
  • All elements are case sensitive
  • The parentheses at the end of a process definition are mandatory (even if empty): <process>()
  • Process names are w+
  • Port names can be [a-zA-Z_]
  • Each line determines a new chain of events, meaning at least two processes with two connecting ports, separated by a " -> " like <process>() <port> -> <port> <process>()
  • Otherwise there is a <initializer> -> <port> <process>()

For better understanding, the whole RegEx used for definition examination is:, (*11)

((?P<inport>[a-zA-Z_]+(\[(?P<inport_no>[0-9]+)\])?)\s)?((?P<process>[\w\/]+)(\((?P<component>[\w\/\\\.]+)?\))?)(\s(?P<outport>[a-zA-Z_]+(\[(?P<outport_no>[0-9]+)\])?))?

Comments: You can add comments and empty lines for better readability and documentation. If you have a comment in the first line, it will be used as name of the definition., (*12)

# this definition reads files and counts their lines
ReadFile() OUT -> IN SplitbyLines()
ReadFile() out -> In SplitbyLines()

# some comment

# and for readability :-)
ReadFile(ReadFile) OUT -> IN SplitbyLines(SplitStr)

Initializer: You can have initial values for a graph:, (*13)

'test.file' -> IN ReadFile()

Multiple definitions: You can have a complete chain of definitions in one line to enhance visibility of a chain of events:, (*14)

GreetUser() DATA -> OPTIONS Render() OUT -> STRING WriteResponse()

Installation

Regular install via composer:, (*15)

composer require phpflo/phpflo-fbp

The Versions

18/04 2017

dev-master

9999999-dev

fbp implementation for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marc Aschmann

flow fbp

26/03 2017

v1.2.0

1.2.0.0

fbp implementation for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marc Aschmann

flow fbp

12/11 2016

v1.1.0

1.1.0.0

fbp implementation for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marc Aschmann

flow fbp

02/11 2016

v1.0.3

1.0.3.0

fbp implementation for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marc Aschmann

flow fbp

30/10 2016

v1.0.2

1.0.2.0

fbp implementation for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marc Aschmann

flow fbp

29/10 2016

v1.0.1

1.0.1.0

fbp implementation for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marc Aschmann

flow fbp

25/09 2016

v1.0.0

1.0.0.0

fbp implementation for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marc Aschmann

flow fbp

18/09 2016

v0.1.0

0.1.0.0

fbp implementation for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marc Aschmann

flow fbp