bear / async
Async/parallel resource execution library for BEAR.Sunday
0.4.0
2026-08-28 16:40 UTC
Requires
- php: ^8.2
- aura/sql: ^5.0 || ^6.0
- bear/app-meta: ^1.6
- bear/package: ^1.14
- bear/resource: ^1.32
- ray/di: ^2.18
Requires (Dev)
- ext-pdo: *
- bamarni/composer-bin-plugin: ^1.4
- brlabrussia/parallel-stub: ^1.1
- phpunit/phpunit: ^11.0
Suggests
- ext-parallel: For parallel thread execution (requires ZTS PHP)
- ext-swoole: For Swoole coroutine support
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-05 18:39:59 UTC
README
Parallel execution of #[Embed] resources for BEAR.Sunday.
#[Embed(rel: 'profile', src: 'app://self/user/profile?id={user_id}')] #[Embed(rel: 'posts', src: 'app://self/user/posts?user_id={user_id}')] #[Embed(rel: 'notifications', src: 'app://self/notifications?user_id={user_id}')] public function onGet(int $user_id): static
These three embeds run in parallel. The resource code does not change; you pick the execution mode at the application boundary.
Installation
composer require bear/async
Execution modes
| Server | Requires | Application change |
|---|---|---|
| PHP-FPM / Apache | ZTS PHP + ext-parallel | add bin/async.php (see manual) |
| Swoole HTTP Server | ext-swoole / ext-openswoole | add a swoole context module that installs AsyncSwooleModule; boot on the compiled injector (see manual) |
Without either extension the same code runs sequentially. A missing extension
fails at configure() with ExtensionNotLoadedException; there is no silent
fallback.
Documentation
- Manual: Parallel Resource Execution — setup, constraints, pool sizing, failure semantics, how it works (日本語)
- Demo guide — Docker-based demo for sequential, ext-parallel, and Swoole
- Benchmark results — cold CLI and steady-state HTTP measurements
- Parallel execution architecture
Demo
cd demo docker compose up -d --wait parallel docker compose exec parallel composer install docker compose exec parallel composer app -- get 'app://self/dashboard?user_id=1' docker compose exec parallel composer async -- get 'app://self/dashboard?user_id=1'
Requirements
PHP 8.2+. Each execution mode adds its own extension requirement (table above).