yuna / flow
2.0.2
2025-11-17 22:55 UTC
Requires
- php: >=8.2
- psr/log: ^3.0
- symfony/config: ^7.3
- symfony/options-resolver: ^7.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.88
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.4
README
Pipeline Builder in PHP.
Features:
- easy to use interfaces
- simple to use
- reusable
- configurable
- fully in PHP (no other extension is supported)
Installation
composer require yuna/flow:^1
Features showcase
Below we can see simple example of usage - how to create pipeline and run it.
<?php
use Yuna\Flow\Config;
use Yuna\Flow\Context;
use Yuna\Flow\Environment;
use Yuna\Flow\FlowBuilder;
use Yuna\Flow\InlineStep;
use Yuna\Flow\Logger;
use Yuna\Flow\Result;
use Yuna\Flow\StepRegistry;
require_once __DIR__ . '/vendor/autoload.php';
$config = new Config();
$context = new Context($config, new Environment($_ENV), new Logger());
$builder = new FlowBuilder(
new StepRegistry([
'@yuna/hello' => new InlineStep(function (Context $context) {
$context->getLogger()?->info('something here');
return new Result(true);
}),
'@yuna/world' => new InlineStep(function (Context $context) {
$context->getLogger()?->info('will error');
return new Result(false);
})
]),
$context
);
$exitCode = $builder
->create()
->run([
'flow' => [
'steps' => [
'Hello' => [
'id' => '@yuna/hello',
],
'World' => [
'id' => '@yuna/world',
]
]
]
]);
exit($exitCode);
Code above will output:
[INFO] Running "Hello"...
[INFO] something here
[INFO] Running "World"...
[INFO] will error
with exit code 1 (because result is false)
Steps requiring configuration
Below we can see example of step requiring configuration.
<?php
use Symfony\Component\OptionsResolver\OptionsResolver;
use Yuna\Flow\Config;
use Yuna\Flow\Context;
use Yuna\Flow\Environment;
use Yuna\Flow\FlowBuilder;
use Yuna\Flow\InlineStep;
use Yuna\Flow\Logger;
use Yuna\Flow\Result;
use Yuna\Flow\StepRegistry;
require_once __DIR__ . '/vendor/autoload.php';
$config = new Config();
$context = new Context($config, new Environment($_ENV), new Logger());
$builder = new FlowBuilder(
new StepRegistry([
'@yuna/require-options' => new InlineStep(
function (Context $context, array $config) {
$context->getLogger()?->info(sprintf('value: %s', $config['value']));
return new Result(true);
},
function (OptionsResolver $resolver) {
$resolver->setRequired('value');
$resolver->setAllowedTypes('value', 'int');
})
]),
$context
);
$exitCode = $builder
->create()
->run([
'flow' => [
'steps' => [
'Hello' => [
'id' => '@yuna/require-options',
'options' => [
'value' => 777
]
]
]
]
]);
exit($exitCode);
Code above will output:
[INFO] Running "Hello"...
[INFO] value: 777
with exit code 0.
That's pretty much it, as you can see, we can pretty easily use different formats, not just PHP.