Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
[READ-ONLY] Subtree split of the Symfony HttpFoundation Component -- clone into Symfony/Component/ (master at symfony/symfony)

Merge branch '2.7'

* 2.7:
  [Form] NativeRequestHandler file handling fix
  [VarDumper] Workaround stringy numeric keys
  [HttpKernel] Throw double-bounce exceptions
  [FrameworkBundle] silence E_USER_DEPRECATED in insulated clients
  [minor] composer.json fix
  [minor] composer.json fix
  Fixed absolute_url for absolute paths
  minor #13377 [Console] Change greater by greater or equal for isFresh in FileResource
  [2.3] [HttpFoundation] fixed param order for Nginx's x-accel-redirect
Failed to load latest commit information.
File Merge branch '2.3' into 2.6
Resources/stubs Merge branch '2.5' into 2.6
Session Merge branch '2.7'
Tests Merge branch '2.7'
.gitignore Added missing files .gitignore
AcceptHeader.php [2.3] CS And DocBlock Fixes
AcceptHeaderItem.php fixed types in phpdocs
ApacheRequest.php [HttpFoundation] do not use server variable PATH_INFO because it is a…
BinaryFileResponse.php Merge branch '2.3' into 2.6 [HttpFoundation] implement different locking strategies for sessions
Cookie.php [2.3] CS And DocBlock Fixes
ExpressionRequestMatcher.php [HttpFoundation] added ExpressionRequestMatcher
FileBag.php Remove aligned '=>' and '='
HeaderBag.php Merge branch '2.3' into 2.5
IpUtils.php [Debug] fix checkip6
JsonResponse.php [3.0] Removed some old hacks
LICENSE Updated copyright to 2015
ParameterBag.php [2.6] CS Fixes And Removed An Unused Import renamed composer.phar to composer to be consistent with the Symfony docs
RedirectResponse.php Docblock fixes
Request.php Merge branch '2.6' into 2.7
RequestMatcher.php [HttpFoundation] Add a way to match a specific scheme in RequestMatch…
RequestMatcherInterface.php Docblock fixes
RequestStack.php unified return null usages
Response.php Merge branch '2.3' into 2.5
ResponseHeaderBag.php Merge branch '2.5' into 2.6
ServerBag.php fix parsing of Authorization header
StreamedResponse.php [HttpFoundation] Allow Cache-Control headers on StreamedResponse
composer.json Merge branch '2.7'
phpunit.xml.dist [PhpUnitBridge] new bridge for testing with PHPUnit

HttpFoundation Component

HttpFoundation defines an object-oriented layer for the HTTP specification.

It provides an abstraction for requests, responses, uploaded files, cookies, sessions, ...

In this example, we get a Request object from the current PHP global variables:

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

$request = Request::createFromGlobals();
echo $request->getPathInfo();

You can also create a Request directly -- that's interesting for unit testing:

$request = Request::create('/?foo=bar', 'GET');
echo $request->getPathInfo();

And here is how to create and send a Response:

$response = new Response('Not Found', 404, array('Content-Type' => 'text/plain'));

The Request and the Response classes have many other methods that implement the HTTP specification.


If you are not using Composer but are using PHP 5.3.x, you must add the following to your autoloader:

// SessionHandlerInterface
if (!interface_exists('SessionHandlerInterface')) {


You can run the unit tests with the following command:

$ cd path/to/Symfony/Component/HttpFoundation/
$ composer install
$ phpunit
Something went wrong with that request. Please try again.