|
1 |
| -# phpflo-fbp |
2 |
| -fbp implementation for php |
| 1 | +# phpflo-fbp: load, parse, dump |
| 2 | +Flowbased programming protocol (fbp) config file loader |
3 | 3 |
|
4 | 4 | [](https://travis-ci.org/phpflo)
|
5 | 5 | [](https://scrutinizer-ci.com/g/phpflo/phpflo-fbp/?branch=master)
|
6 | 6 | [](https://scrutinizer-ci.com/g/phpflo/phpflo-fbp/?branch=master)
|
| 7 | +[](http://doge.mit-license.org) |
7 | 8 |
|
8 | 9 |
|
9 |
| -license MIT |
| 10 | +## Introduction |
| 11 | + |
| 12 | +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. |
| 13 | +Supported config formats are json (.json), yaml (.yml) and fbp (.fbp), output is array. |
| 14 | + |
| 15 | +## Code Samples |
| 16 | + |
| 17 | +Basic usage: |
| 18 | +```php |
| 19 | +// load fbp config |
| 20 | +$defintiion = \PhpFlo\Loader\Loader::load('my/fbp/config/file.fbp'); |
| 21 | +``` |
| 22 | +You can load json, yml and fbp that way. |
| 23 | + |
| 24 | +Parser by itself: |
| 25 | +```php |
| 26 | +$myFbpConfig = <<<EOF |
| 27 | +'test.file' -> IN ReadFile(ReadFile) |
| 28 | +ReadFile(ReadFile) OUT -> IN SplitbyLines(SplitStr) |
| 29 | +ReadFile ERROR -> IN Display(Output) |
| 30 | +SplitbyLines OUT -> IN CountLines(Counter) |
| 31 | +CountLines COUNT -> IN Display |
| 32 | +EOF; |
| 33 | + |
| 34 | +$parser = new \PhpFlo\Fbp\FbpParser(); |
| 35 | +$definition = $parser->run($myFbpConfig); |
| 36 | +``` |
| 37 | +Dump your flow to a format: |
| 38 | +```php |
| 39 | +$json = \PhpFlo\Fbp\FbpDumper::toJson($definition); |
| 40 | +$yaml = \PhpFlo\Fbp\FbpDumper::toYaml($definition); |
| 41 | +$fbp = \PhpFlo\Fbp\FbpDumper::toFbp($definition); |
| 42 | +``` |
| 43 | + |
| 44 | +The definition has following schema: |
| 45 | +```php |
| 46 | +$schema = [ |
| 47 | + 'properties' => ['name' => '',], |
| 48 | + 'initializers' => [ |
| 49 | + [ |
| 50 | + 'data' => '', |
| 51 | + 'tgt' => [ |
| 52 | + 'process' => '', |
| 53 | + 'port' => '', |
| 54 | + ], |
| 55 | + ], |
| 56 | + ], |
| 57 | + 'processes' => [ |
| 58 | + 'ReadFile' => [ |
| 59 | + 'component' => '', |
| 60 | + 'metadata' => [ |
| 61 | + 'label' => '', |
| 62 | + ], |
| 63 | + ], |
| 64 | + ], |
| 65 | + 'connections' => [ |
| 66 | + [ |
| 67 | + 'src' => [ |
| 68 | + 'process' => '', |
| 69 | + 'port' => '', |
| 70 | + ], |
| 71 | + 'tgt' => [ |
| 72 | + 'process' => '', |
| 73 | + 'port' => '', |
| 74 | + ], |
| 75 | + ], |
| 76 | + ], |
| 77 | +] |
| 78 | +``` |
| 79 | + |
| 80 | +## Installation |
| 81 | + |
| 82 | +Regular install via composer: |
| 83 | +```php |
| 84 | +composer require phpflo/phpflo-fbp |
| 85 | +``` |
0 commit comments