symfony/http-foundation
Symfony HttpFoundation provides an object-oriented API for HTTP: requests, responses, headers, cookies, sessions, and file uploads. It normalizes PHP’s globals into consistent objects, making it easier to build and test web applications and middleware.
Content-Range, ETag) is non-negotiable.HttpClient for inter-service calls, where unified request/response handling reduces friction.$_SERVER parsing with structured ServerBag).HttpClient, Cache, and Routing components reduces context-switching costs for teams using both stacks. The beta release signals stability for PHP 8.1+ projects (e.g., Laravel 10+).Request class now better supports Symfony’s Middleware interface, easing Laravel middleware adaptation (e.g., TrustProxiesMiddleware).StreamedResponse and JsonResponse classes align with Laravel’s Response but offer lower-level control (e.g., custom Content-Type negotiation).Request/Response only for API routes via service provider bindings (e.g., when() conditions in Laravel’s container).HttpFoundation classes can coexist with Laravel’s Illuminate\Http via alias bindings (e.g., Symfony\Component\HttpFoundation\Request → Illuminate\Http\Request).database/redis session drivers may still require wrapper classes to handle Symfony’s Session interface.UploadedFile class now includes bug fixes for error handling (e.g., getErrorMessage()), but Laravel’s Illuminate\Http\UploadedFile may need adapter methods for consistency (e.g., getClientOriginalName()).v8.1.0-BETA3 release introduces hardening fixes (e.g., #64269), but beta software carries risk. Mitigation:
^8.0 for now; avoid ^8.1 until RC/stable.Request class in production.VerifyCsrfToken) assumes Illuminate\Http\Request. Action: Test with the package’s Request early and create adapters if needed.Request parsing speed (Symfony’s ServerBag vs. Laravel’s Request).Response generation (e.g., JsonResponse serialization).composer dump-autoload --optimize) and conditional loading (e.g., load only in API contexts).v8.1.0-BETA3. Laravel 10+ aligns, but Laravel 9.x projects must:
symfony/http-foundation:^7.4 (stable for PHP 8.0).empty session data fixes).v8.1.0-BETA3 in staging before upgrading, or wait for RC/stable?TrustProxies, Localization) adapt to the package’s Request class?Session, how will Laravel’s database/redis drivers handle Symfony’s Session interface?PdoSessionHandler vs. Laravel’s DatabaseSessionHandler.actingAs()) adapt to the new Request class?Request class in PHPUnit.Symfony\Component\HttpFoundation\Request to Laravel’s container via a service provider, with fallback to Illuminate\Http\Request for non-API routes.HttpFoundation facade to mirror Laravel’s Request/Response facades, with conditional logic for route-based switching.Symfony\Component\HttpFoundation\Request via a custom resolver.// app/Providers/HttpFoundationServiceProvider.php
public function register()
{
$this->app->bind(
Symfony\Component\HttpFoundation\Request::class,
fn() => Symfony\Component\HttpFoundation\Request::createFromGlobals()
);
// Fallback for non-API routes
$this->app->when(Request::class)
->needs(Symfony\Component\HttpFoundation\Request::class)
->give(fn() => new Symfony\Component\HttpFoundation\Request());
}
empty session data fix in v8.1.0-BETA3).symfony/http-foundation:^7.4) to avoid breaking changes.Phase 1: Pilot Integration (Low Risk)
composer require symfony/http-foundation:^8.0.Symfony\Component\HttpFoundation\Request alongside Laravel’s Request.Request class.Phase 2: Selective Replacement (Medium Risk)
Request/Response in specific modules (e.g., admin panel, API).Request class (e.g., via middleware).Response with Symfony\Component\HttpFoundation\Response where needed (e.g., for custom headers).UploadedFile (test with getErrorMessage() fixes).Phase 3: Full Adoption (High Risk)
Symfony\Component\HttpFoundation\Session (test with PdoSessionHandler).Request class.Symfony\Component\HttpFoundation\Request.Validator expects Illuminate\Http\Request. Use a wrapper to adapt Symfony\Component\HttpFoundation\Request.LocaleMiddleware. Reimplement or use a composite middleware.How can I help you explore Laravel packages today?