darkwood / flow
Flow
Requires
- php: >=8.5
- symfony/config: ^8.1
- symfony/dependency-injection: ^8.1
- symfony/event-dispatcher: ^8.1
- symfony/http-kernel: ^8.1
- symfony/string: ^8.1
Requires (Dev)
- amphp/amp: ^3.1
- doctrine/dbal: ^4.3
- openswoole/ide-helper: ^26.2.0
- react/async: ^4.3
- spatie/async: ^1.8
- symfony/doctrine-messenger: ^8.1
- symfony/http-client: ^8.1
Suggests
- ext-async: Provides the experimental TrueAsync driver for Flow
- ext-openswoole: Provide asynchronous with OpenSwoole
- amphp/amp: Provide asynchronous with AMP
- react/async: Provide asynchronous with ReactPHP
- spatie/async: Provide asynchronous with Spatie
- symfony/messenger: Provide Symfony Messenger support
Provides
None
Conflicts
None
Replaces
None
- 9.0.x-dev
- 8.1.x-dev
- v8.1.6
- v8.1.5
- v8.1.3
- v8.1.2
- v8.1.1
- v8.1.0
- 8.0.x-dev
- v8.0.13
- 1.3.0
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- 1.0.x-dev
- dev-cleanup-batch-async-handler
- dev-1.x-dev
- dev-driver-defer-only
- dev-generic-errors
- dev-symplely
- dev-lazy-stream
- dev-grpc
- dev-supply-chain
- dev-webhooks
This package is auto-updated.
Last update: 2026-11-23 09:34:35 UTC
README
Why ?
Flow concept aims to solve
- Adopt asynchronous as native implementation
- Build your code with functional programming
- Assemble your code visually
Installation
PHP 8.5 is the minimal version to use Flow The recommended way to install it through Composer and execute
composer require darkwood/flow
Usage
<?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();
Error semantics
For backward compatibility, exceptions thrown by a job are resolved by the
driver as Flow\Exception\RuntimeException values. If a step defines an
errorJob, that job receives the value. Otherwise the value continues to the
next step like any other result; await() does not throw it automatically.
Callback, listener and runtime failures remain infrastructure exceptions.
Completion paths release their Flow-owned IP state before await() propagates
the failure. This historical job-error contract is intentionally unchanged in
the current release.
Examples
A working script is available in the bundled examples directory
- Run Flow :
php examples/flow.php - Run Y-Combinator Flow :
php examples/yflow.php - Start Server :
php examples/server.php
Start Client(s) :php examples/client.php
Documentation
https://darkwood-com.github.io/flow
License
Flow is released under the MIT License.
Shared PHP development environment
In the Darkwood monorepo, the existing Castor flow:tools:env task opens the
canonical Navi shell through its native Nix file entry point. It uses the Navi
environment lock and does not snapshot the application or start local services.
The standalone package retains its previous external shell fallback when the
monorepo Navi directory is unavailable. This development integration adds no
Navi runtime dependency and leaves Flow's Composer files and drivers unchanged.