php-standard-library/async
Fiber-based async primitives for PHP: structured concurrency with cooperative multitasking. Run tasks concurrently, manage lifecycles, cancellations, and scopes predictably. Part of PHP Standard Library; docs and guides at php-standard-library.dev.
Illuminate\Support\Facades\Promise (if using Laravel 8+) or third-party libraries like spatie/async/spatie/promise.Illuminate\Queue) is mature, this package could augment job orchestration (e.g., fan-out/fan-in patterns, dynamic task grouping) without replacing it.Async::run()).Promise, but this package’s implementation might differ in error handling or chaining syntax. Test compatibility early.DB::async()) are risky in Laravel due to connection pooling. The package should explicitly address this or provide safeguards.Monolog) and exception handling (App\Exceptions\Handler). Test edge cases like:
Async::fake()).illuminate/support (Promise facades).spatie/async or amphp/async.spatie/async or Swoole.Async::later() → dispatch()).illuminate/support for hybrid sync/async code.Async::onEvent()).react/promise or spatie/async.Async::parallel()).Async::task() to validate performance/gains.// Before: Queue job
Dispatch(new ProcessPayment($userId));
// After: Async task
Async::task(fn() => ProcessPayment::run($userId))->await();
Async::parallel() for fan-out (e.g., calling multiple APIs):
$results = Async::parallel([
fn() => fetchUserData($userId),
fn() => fetchOrderData($orderId),
])->await();
Async::then()/Async::catch().public function handle(Request $request, Closure $next) {
return Async::run(fn() => $next($request))->await();
}
Async task durations in Sentry).DB::connection()->getPdo() for async DB access (if supported).$this->app->singleton(Async::class, fn() => new Async());
config/async.php for:
Async in unit tests:
Async::shouldReceive('task')->andReturn(new MockPromise());
refreshDatabase() with async seeders.Async vs. queues.illuminate/support (Promise API).SPL (for iterators used in async loops).Async::debug() (if provided).dd() with Async::pause() (if supported).Async::then()/Async::catch().Async::catch() → report()).Async::task($task)
->catch(fn(Throwable $e) => report($e));
Async::setConcurrency(5) to avoid overwhelming the app.How can I help you explore Laravel packages today?