PHP Async Frameworks
debt(d7/e7/b7/t7)
Closest to 'only careful code review or runtime testing' (d7). The detection_hints indicate automated detection is 'no' and the only listed tool is Blackfire (a profiler/performance tool). Blocking I/O inside an async event loop — the primary common mistake — will not be flagged by a linter or compiler; it silently stalls the entire event loop and is only discoverable through profiling under load or careful code review. Blackfire can surface it post-facto but doesn't prevent it at write-time.
Closest to 'cross-cutting refactor across the codebase' (e7). The quick_fix describes choosing between ReactPHP and Amp, but the common_mistakes (blocking I/O, sync PDO in async context) indicate that fixing misuse requires identifying and replacing all synchronous I/O calls and library usages throughout the codebase with async-compatible alternatives. PHP libraries written for synchronous execution 'cannot be used directly without wrappers' per why_it_matters — this is inherently cross-cutting, touching many files and dependencies.
Closest to 'strong gravitational pull' (b7). The programming model is 'fundamentally different' per why_it_matters, and every I/O operation, library choice, error handling pattern, and database call must be evaluated for async compatibility. The event loop shapes all subsequent code decisions in the service, and applies to cli and queue-worker contexts where it is the architectural backbone. Every future maintainer must understand the async model to work safely in the codebase.
Closest to 'serious trap' (t7). The misconception field explicitly states developers believe 'ReactPHP replaces PHP-FPM for web apps' when it doesn't — it contradicts the intuition that async = better concurrency everywhere. Additionally, the common mistake of using blocking calls (sync PDO, blocking I/O) inside the event loop contradicts how developers accustomed to traditional PHP or Node.js async patterns would expect things to work. The 'obvious' approach of using familiar synchronous PHP libraries breaks the entire event loop silently.
Also Known As
TL;DR
Explanation
ReactPHP: event-driven, non-blocking I/O built on PHP streams. Amp v3: coroutine-based using PHP 8.1 Fibers. Both enable concurrent HTTP requests to multiple APIs simultaneously. Use where a service makes many external API calls — sequential calls taking N*latency become ~1*latency with concurrency.
Common Misconception
Why It Matters
Common Mistakes
- Blocking I/O inside async loop
- Using sync PDO in async context
- Not handling promise rejection
- Async for sequential workflows
Code Examples
foreach ($apis as $url) { $results[] = file_get_contents($url); } // 10s serial
$browser = new Browser();
$promises = array_map(fn($u) => $browser->get($u), $apis);
\React\Promise\all($promises)->then(fn($r) => process($r));
Loop::run(); // ~1s