darkwood/flow
Flow is a PHP 8.5+ package for asynchronous, functional pipelines. Use FlowFactory to compose yielded callables into reusable flows, pass input through Ip, and await results. It supports visual code assembly and ships with examples for flows, Y-combinator, and server/client usage.
Flow concept aims to solve
PHP 8.5 is the minimal version to use Flow The recommended way to install it through Composer and execute
composer require darkwood/flow
<?php
use Flow\Flow\Flow;
use Flow\FlowFactory;
use Flow\Ip;
class D1 {
public function __construct(public int $n1) {}
}
class D2 {
public function __construct(public int $n2) {}
}
class D3 {
public function __construct(public int $n3) {}
}
class D4 {
public function __construct(public int $n4) {}
}
$flow = (new FlowFactory())->create(static function() {
yield fn (D1 $data1) => new D2($data1->n1 += 1);
yield fn (D2 $data2) => new D3($data2->n2 * 2);
yield function(D3 $data3) {
printf("my number %d\n", $ip->data->n3)); // display 'my number 10'
return new D4($data3->n3);
};
});
$ip = new Ip(new D1(4));
$flow($ip);
$flow->await();
A working script is available in the bundled examples directory
php examples/flow.phpphp examples/yflow.phpphp examples/server.phpphp examples/client.phphttps://darkwood-com.github.io/flow
Flow is released under the MIT License.
How can I help you explore Laravel packages today?