beauty-framework / parallels
Beauty Parallels (RoadRunner, Fibers)
Installs: 13
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/beauty-framework/parallels
Requires
- php: >=8.1
- opis/closure: ^4.3
- spiral/roadrunner-jobs: ^4.6
This package is not auto-updated.
Last update: 2025-10-15 09:51:01 UTC
README
A lightweight concurrency manager for PHP, supporting Fiber-based parallel execution out of the box. Optionally, you can use RoadRunner jobs-based parallelism (WIP).
Installation
composer require beauty-framework/parallels
Quick Start
use Beauty\Parallels\Concurrent; use Beauty\Parallels\WorkersName; $results = Concurrent::run([ 'task-1' => fn() => 1 + 1, 'task-2' => fn() => strtoupper('hello'), ]); print_r($results);
Output:
[
'task-1' => 2,
'task-2' => 'HELLO',
]
Execution Modes
Concurrent::run(array $callbacks, int $timeoutSeconds = 10, string $type = WorkersName::FIBER): array
Available modes:
| Mode | Description |
|---|---|
fiber |
Default. Uses PHP Fibers (cooperative multitasking) |
process |
WIP. Spawns tasks via RoadRunner Jobs pipeline |
You can explicitly choose the execution strategy:
Concurrent::run([ 'a' => fn() => 42, ], 5, WorkersName::FIBER);
Notes
- Fiber-based mode is enabled by default, lightweight and fast.
- RoadRunner-based process execution is under active development and is experimental.
TODO
- Finish implementation of
ProcessConcurrencyWorkerbased onspiral/roadrunner-jobs - Add serialization-safe closures via
opis/closure - Result collector with Redis or temp files
- Per-task exception handling and cancellation support
- Tests
License
MIT