phpflo-fbp

所属分类:collect
开发工具:PHP
文件大小:0KB
下载次数:0
上传日期:2017-05-01 09:31:47
上 传 者sh-1993
说明:  [只读]子树拆分-基于流的编程协议(fbp)配置文件加载器、解析器和转储器,
([READONLY] subtree split - Flowbased programming protocol (fbp) config file loader, parser and dumper,)

文件列表:
.travis.yml (91, 2017-04-18)
CHANGELOG.md (693, 2017-04-18)
FbpDefinition.php (2619, 2017-04-18)
FbpDumper.php (6507, 2017-04-18)
FbpParser.php (10730, 2017-04-18)
LICENSE (1063, 2017-04-18)
Loader/ (0, 2017-04-18)
Loader/Loader.php (2844, 2017-04-18)
Test/ (0, 2017-04-18)
Test/TestCase.php (536, 2017-04-18)
Tests/ (0, 2017-04-18)
Tests/FbpDefinitionTest.php (3954, 2017-04-18)
Tests/FbpDumperTest.php (7202, 2017-04-18)
Tests/FbpParserTest.php (16476, 2017-04-18)
Tests/Loader/ (0, 2017-04-18)
Tests/Loader/LoaderTest.php (4944, 2017-04-18)
composer.json (722, 2017-04-18)
phpunit.xml.dist (1025, 2017-04-18)

# [READONLY] phpflo-fbp: load, parse, dump Flowbased programming protocol (FBP) config file loader, using the FBP domain specific language (DSL). [![Build Status](https://travis-ci.org/phpflo/phpflo-fbp.svg?branch=master)](https://travis-ci.org/phpflo) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phpflo/phpflo-fbp/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/phpflo/phpflo-fbp/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/phpflo/phpflo-fbp/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/phpflo/phpflo-fbp/?branch=master) [![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org) ## 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. ## Code Samples Basic usage: ```php // load FBP config $defintiion = PhpFlo\Loader\Loader::load('my/fbp/config/file.fbp'); ``` You can load JSON, YAML and FBP that way. Parser by itself: ```php $myFbpConfig = << 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: ```php $json = PhpFlo\Fbp\FbpDumper::toJson($definition); $yaml = PhpFlo\Fbp\FbpDumper::toYaml($definition); $fbp = PhpFlo\Fbp\FbpDumper::toFbp($definition); ``` The definition has following schema: ```php $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: *General syntax*: ``` // () <[optional_port_number]> -> <[optional_port_number]> () // 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 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 ```() -> ()``` * Otherwise there is a ``` -> ()``` For better understanding, the whole RegEx used for definition examination is: ``` ((?P[a-zA-Z_]+(\[(?P[0-9]+)\])?)\s)?((?P[\w\/]+)(\((?P[\w\/\\\.]+)?\))?)(\s(?P[a-zA-Z_]+(\[(?P[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. ``` # 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: ``` '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: ``` GreetUser() DATA -> OPTIONS Render() OUT -> STRING WriteResponse() ``` ## Installation Regular install via composer: ```php composer require phpflo/phpflo-fbp ```

近期下载者

相关文件


收藏者