# symfony/http-foundation

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/symfony-http-foundation).**

8,630 stars · 307 forks · PHP · MIT

## Links

- GitHub: https://github.com/symfony/http-foundation
- Homepage: https://symfony.com/http-foundation
- awesome-repositories: https://awesome-repositories.com/repository/symfony-http-foundation.md

## Topics

`component` `php` `symfony` `symfony-component`

## Description

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.

## Tags

### Web Development

- [HTTP Request-Response Object Layers](https://awesome-repositories.com/f/web-development/http-request-response-object-layers.md) — Provides the foundational object-oriented layer for modeling HTTP requests and responses in PHP.
- [Request Data Accessors](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-request-handling/request-data-accessors.md) — Provides structured property objects for reading query, body, cookies, files, and headers from incoming requests. ([source](https://symfony.com/doc/current/components/http_foundation.html))
- [HTTP Response Builders](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-utilities/http-response-builders.md) — Ships a structured object for constructing and sending HTTP responses with status codes, headers, and body content. ([source](https://cdn.jsdelivr.net/gh/symfony/http-foundation@8.2/README.md))
- [Header Bag Management](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-utilities/http-response-builders/header-bag-management.md) — Manages HTTP response headers through a dedicated bag object with methods for cache control, cookies, and content negotiation.
- [Raw HTTP Request Construction](https://awesome-repositories.com/f/web-development/raw-http-request-construction.md) — Wraps raw PHP superglobals into structured objects with methods for headers, parameters, and file uploads. ([source](https://cdn.jsdelivr.net/gh/symfony/http-foundation@8.2/README.md))
- [Response Streaming](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-response-handling/response-streaming.md) — Sends response content incrementally using callables or iterables for large payloads and real-time data. ([source](https://symfony.com/doc/current/components/http_foundation.html))
- [Request Simulators](https://awesome-repositories.com/f/web-development/backend-development/web-frameworks/routing-request-handling/http-request-handlers/request-simulators.md) — Allows creating request objects from URIs and parameters without relying on PHP superglobals for testing. ([source](https://symfony.com/doc/current/components/http_foundation.html))
- [HTTP Redirects](https://awesome-repositories.com/f/web-development/http-redirects.md) — Sends HTTP redirect responses with status codes and location headers to guide clients to different URLs. ([source](https://symfony.com/doc/current/components/http_foundation.html))
- [JSON Response Formatters](https://awesome-repositories.com/f/web-development/response-formatting/json-response-formatters.md) — Encodes data as JSON and sets the appropriate Content-Type header for API responses. ([source](https://symfony.com/doc/current/components/http_foundation.html))
- [Streaming Response Handlers](https://awesome-repositories.com/f/web-development/streaming-response-handlers.md) — Supports sending response content incrementally, including JSON streaming and server-sent events.
- [URL Generation](https://awesome-repositories.com/f/web-development/url-generation.md) — Converts paths into absolute or relative URLs for use in responses or links. ([source](https://symfony.com/doc/current/components/http_foundation.html))

### Networking & Communication

- [Request Matching](https://awesome-repositories.com/f/networking-communication/communication-protocols-architectures/request-processing-architectures/request-matching.md) — Implements composable matcher classes that check requests against IP, method, host, or path conditions. ([source](https://symfony.com/doc/current/components/http_foundation.html))
- [Cookie Objects](https://awesome-repositories.com/f/networking-communication/http-clients/http-cookie-management/cookie-objects.md) — Represents HTTP cookies as dedicated objects with configurable attributes for domain, path, expiration, and security flags.
- [Parameter Bag Abstractions](https://awesome-repositories.com/f/networking-communication/http-request-abstractions/parameter-bag-abstractions.md) — Wraps PHP superglobals into typed parameter bag objects for structured access to query, body, cookies, and headers.
- [Request Matchers](https://awesome-repositories.com/f/networking-communication/network-infrastructure-routing/network-routing-traffic-management/request-routing/request-matchers.md) — Checks incoming requests against composable rules for IP, method, host, or path using dedicated matcher classes.
- [Composable Request Matchers](https://awesome-repositories.com/f/networking-communication/communication-protocols-architectures/request-processing-architectures/request-matching/composable-request-matchers.md) — Provides composable matcher classes that check requests against IP, method, host, or path conditions.
- [Composable](https://awesome-repositories.com/f/networking-communication/network-infrastructure-routing/network-routing-traffic-management/request-routing/request-matchers/composable.md) — Provides composable matcher classes that check requests against IP, method, host, or path conditions.
- [Server-Sent Events](https://awesome-repositories.com/f/networking-communication/server-sent-events.md) — Pushes real-time updates over a single long-lived HTTP connection using a structured event stream format.

### Security & Cryptography

- [Cookie Objects](https://awesome-repositories.com/f/security-cryptography/cookie-management/cookie-objects.md) — Provides dedicated cookie objects with configurable attributes for attaching to HTTP responses. ([source](https://symfony.com/doc/current/components/http_foundation.html))

### Data & Databases

- [Session Storage](https://awesome-repositories.com/f/data-databases/data-engineering-infrastructure/data-persistence-storage/data-storage/session-storage-synchronization/session-storage.md) — Manages user session data across requests through a server-side storage mechanism decoupled from request handling.
- [HTTP Cache Headers](https://awesome-repositories.com/f/data-databases/performance-caching-systems/page-caching-controls/http-cache-headers.md) — Manages cache-control, expiration, ETag, and last-modified headers for HTTP caching.
- [Server-Side Session Stores](https://awesome-repositories.com/f/data-databases/session-state-management/server-side-session-stores.md) — Provides server-side storage and retrieval of user session information across HTTP requests.

### DevOps & Infrastructure

- [HTTP Range Request Handling](https://awesome-repositories.com/f/devops-infrastructure/caching-layers/range-aware-caching/http-range-request-handling.md) — Serves files with automatic support for HTTP range requests and optional X-Sendfile delegation to the web server.
- [Range Request File Servings](https://awesome-repositories.com/f/devops-infrastructure/file-uploaders/s3-file-uploads/public-file-serving/range-request-file-servings.md) — Ships a file serving component with automatic range request handling and X-Sendfile delegation. ([source](https://symfony.com/doc/current/components/http_foundation.html))
