php-standard-library/promise
Lightweight PHP promise implementation for composing and coordinating async-style workflows. Create, resolve, reject, and chain promises with then/catch-style handlers, useful for deferred results, task pipelines, and bridging callback-based APIs into a cleaner flow.
dispatch() calls in Promises for chaining).catch blocks must still use callbacks, which could lead to inconsistent error surfaces if not disciplined.Mockery or custom test doubles).Illuminate\Support\Facades\Bus or Illuminate\Queue suffice, or is a Promise layer necessary for composability?Promise::all([job1(), job2()])).event1.then(() => event2)).Promise facade for global access.Bus or Queue to return Promises natively.Mockery to stub Promise resolutions in unit tests.Guzzle requests → Promise::all → process responses).Promise::dispatch($job)) to wrap Laravel Queues.Promise::race(), Promise::any()) for common patterns.dispatch() calls but won’t replace the queue system.GuzzlePromise::send($request)).Event::dispatch() with Promises for async listeners.Promise::allSettled())..then() chaining).finally for cleanup).Promise::all() with many slow operations) may need batching.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Unhandled Promise rejection | Silent crashes or partial failures | Global set_unhandled_rejection_handler() |
| Circular Promise dependencies | Memory leaks or deadlocks | Static analysis tools (e.g., Psalm) |
| Queue worker crashes | Broken async flows | Retry logic + Sentry alerts |
| Promise leak (unresolved) | Memory bloat | finally blocks or TTL for Promises |
| Mixed sync/async code | Race conditions | Clear architecture boundaries (e.g., "Promises only in X layer") |
.then() chains).Promise::resolve() stubs).How can I help you explore Laravel packages today?