darkwood/flow
Flow is a PHP 8.5+ package for building asynchronous pipelines with a functional style. Define steps with generators, pass typed data through each stage, and await execution. Includes examples and docs, with a focus on assembling code as “flows”.
pdo_mysql, redis).spatie/async, amphp/amp).Ip (Input/Process) pattern could replace Laravel’s Request object in async contexts, but conflicts with Laravel’s service container (e.g., binding Ip to Illuminate\Http\Request).App\Exceptions\Handler) may not propagate Flow’s async errors cleanly. Requires custom DriverInterface implementations.FlowFactory and drivers.spatie/async) for throughput.Ip from polluting Laravel’s request context (e.g., middleware, service container)?AmpDriver (for HTTP) or ReactDriver (for event loops) to integrate with Laravel’s existing async tools (e.g., spatie/async, laravel-echo).FlowMiddleware to wrap async flows in Laravel’s request lifecycle (e.g., handle() method).FlowFactory only where needed (e.g., app/Providers/FlowServiceProvider.php).Laravel Job using spatie/async to a Flow pipeline.LaravelDriver extending Flow\DriverInterface to bridge with Laravel’s event loop.ReactPHP’s event loop for both Flow and Laravel Echo.FlowMiddleware to handle async flows in HTTP requests (e.g., for real-time APIs).public function handle(Request $request, Closure $next) {
$flow = (new FlowFactory())->create(fn() => yield $this->processRequest($request));
$flow->await(); // Blocking; consider offloading to a queue.
return $next($request);
}
spatie/async for simple cases).spatie/data-transfer-object) as intermediaries.Validator works with Flow if inputs are converted to DTOs before processing.Ip data.spatie/async or amphp/amp in the same pipeline to prevent driver conflicts.Mockery to stub FlowFactory and drivers in PHPUnit tests.FlowMiddleware to specific routes (e.g., /api/process) before app-wide adoption.spatie/async).app/Design/Flow) to standardize:
Ip, DTOs).AmpDriver for HTTP").amphp/amp) may introduce breaking changes if Laravel’s async stack evolves.monolog to log Ip state at each step.flow:dump (custom command) to inspect pipelines.$flow->onStep(fn($step) => Log::debug("Step {$step->name}:", $step->data));
FlowFactory and drivers.pestphp’s async testing helpers or react/testing.AmpDriver timeouts).FLOW.md to the Laravel repo with:
#flow channel in Slack/Discord for async-specific issues.Ip is serialized) enables horizontal scaling in queues.laravel-horizon to distribute Flow jobs across workers.SwooleDriver: Best for high concurrency (but requires Swoole extension).AmpDriver: Best for I/O-bound tasks (e.g., HTTP requests).Ip streams).How can I help you explore Laravel packages today?