Search by

bear / async

koriym

Async/parallel resource execution library for BEAR.Sunday

0.4.0 2026-08-28 16:40 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

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).