drift/http-kernel is a Symfony HttpKernel wrapper with ReactPHP Promise-based async support, making it a strong candidate for Laravel applications requiring non-blocking I/O (e.g., real-time APIs, event-driven workflows, or high-concurrency microservices). It aligns with Laravel’s growing adoption of async features (e.g., Laravel 10’s Swoole/RoadRunner support) but provides a Symfony-compatible abstraction layer.HttpKernel, enabling async request handling while maintaining compatibility with middleware, controllers, and routing. This is particularly valuable for:
drift/async, drift/orm), this kernel acts as a unified entry point, reducing fragmentation.HttpKernel, it preserves Laravel’s middleware stack (including Illuminate\Pipeline). Controllers and route definitions remain unchanged, but async handlers (e.g., ReactPHP-backed responses) can be introduced.drift/orm or ReactDBAL).GuzzleHttp with async clients).Laravel Horizon or DriftPHP’s async queue).router.php but may require custom middleware to bridge sync/async boundaries (e.g., converting Symfony\Component\HttpFoundation\Request to Psr\Http\Message\RequestInterface).| Risk Area | Mitigation Strategy |
|---|---|
| Middleware Conflicts | Test with Laravel’s core middleware (e.g., VerifyCsrfToken, Authenticate). |
| Async Deadlocks | Profile with Xdebug/Tideways to detect blocking calls in async contexts. |
| Dependency Bloat | ReactPHP adds ~10MB to footprint; benchmark memory usage in production-like loads. |
| Laravel-Specific Gaps | Some Laravel features (e.g., Request facade, Response macros) may need adapters. |
| Debugging Complexity | Async stack traces are harder to debug; invest in structured logging (e.g., Monolog + ReactPHP handlers). |
Auth) interact with async handlers?drift/orm or ReactDBAL be used? If not, how will async DB calls be handled?PestPHP + ReactPHP assertions)?Swoole/RoadRunner).Promise features and Laravel’s async improvements.drift/async, drift/orm, or drift/queue, this kernel provides a unified async layer.ReactPHP-based libraries (e.g., React\Http, React\Socket).Laravel Horizon, Laravel Echo, or Laravel Vapor./async-health).drift/http-kernel.// routes/web.php
Route::get('/sync', [Controller::class, 'syncMethod']);
Route::get('/async', [Controller::class, 'asyncMethod'])
->middleware('async_kernel'); // Custom middleware to switch kernels
app/KernelResolver.php) to dynamically select sync/async.app/Providers/AppServiceProvider.php:
public function register()
{
$this->app->singleton(\Illuminate\Contracts\Http\Kernel::class, function ($app) {
return new \Drift\HttpKernel\Kernel($app);
});
}
| Component | Compatibility Notes |
|---|---|
| Middleware | Most middleware will work, but stateful middleware (e.g., sessions) may need async adapters. |
| Controllers | Standard controllers work; async methods should return PromiseInterface. |
| Routing | Laravel’s router works, but async route handlers require ReactPHP-aware responses. |
| Validation | Illuminate\Validation is sync; use ReactPHP-compatible validators if needed. |
| Queue Workers | Can integrate with drift/queue or Laravel Horizon for async job processing. |
| Testing | PHPUnit tests may need ReactPHP assertions (e.g., await()). |
drift/http-kernel and reactphp/promise.React\EventLoop\Factory).DB::select(), Http::get()) with async equivalents.use React\Promise\PromiseInterface;
public function asyncMethod(): PromiseInterface
{
return \Drift\Async::db()->select('users')->then(function ($users) {
return response()->json($users);
});
}
try {
return $asyncKernel->handle($request);
} catch (AsyncException $e) {
return $syncKernel->handle($request);
}
ext-swoole, ext-event, etc.). Monitor for CVE updates.drift/http-kernel releases.Monolog + ReactPHP handlers).OpenTelemetry with ReactPHP instrumentation).Tideways or Blackfire for profiling.Swoole, ReactPHP loop).How can I help you explore Laravel packages today?