Symfony HttpFoundation is an object-oriented library that models HTTP requests and responses as structured objects, wrapping PHP superglobals into typed parameter bags and providing dedicated objects for headers, cookies, and file uploads. It serves as the foundational layer for building HTTP-based applications in PHP, offering a complete abstraction for reading request data, constructing responses, and managing the full request-response lifecycle.
The library distinguishes itself through composable request matchers that check incoming requests against conditions like IP, method, host, or path, and through its support for streaming responses and server-sent events for real-time data delivery. It also provides session storage abstraction for managing user data across requests, HTTP cache header management for controlling client and proxy caching behavior, and file serving with automatic range request handling and optional X-Sendfile delegation.
Additional capabilities include JSON API response handling, URL generation for converting paths into absolute or relative URLs, and cookie management through dedicated cookie objects with configurable attributes. The library also supports request simulation for testing and development without relying on PHP superglobals.