Skip to content


Subversion checkout URL

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

Merge branch '2.8'

* 2.8: (21 commits)
  Fix merge
  Fix typo
  Various fixes esp. on Windows
  Fix the validation of form resources to register the default theme
  Fix the retrieval of the value with property path when using a loader
  [appveyor] minor enhancements
  [Process] Disable failing tests on Windows
  [Translation] Fix the string casting in the XliffFileLoader
  Windows and Intl fixes
  Add appveyor.yml for C.I. on Windows
  [VarDumper] fixed HtmlDumper to target specific the head tag
  [travis] merge php: nightly and deps=high test-matrix lines
  consistently use str_replace to unify directory separators
  Support omitting the <target> node in an .xlf file.
  Fix the handling of values for multiple choice types
  moved PHP nightly to PHP 7.0
  fixed tests using deprecation features
  [Form] made deprecation notice more precise
  fixed CS
  Fix BC break after split of ACL from core

Failed to load latest commit information.
File Merge branch '2.6' into 2.7
Resources/stubs Merge branch '2.5' into 2.6
Session Merge branch '2.8'
Tests Merge branch '2.8'
.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 fixes CS [HttpFoundation] implement different locking strategies for sessions
Cookie.php CS: Convert double quotes to single quotes
ExpressionRequestMatcher.php [HttpFoundation] added ExpressionRequestMatcher
FileBag.php [2.3] Static Code Analysis for Components
HeaderBag.php Merge branch '2.3' into 2.5
IpUtils.php [HttpFoundation] IpUtils::checkIp4() should allow networks
JsonResponse.php Remove code for PHP <5.5.9
LICENSE Updated copyright to 2015
ParameterBag.php Merge branch '2.3' into 2.6 renamed composer.phar to composer to be consistent with the Symfony docs
RedirectResponse.php Docblock fixes
Request.php Merge branch '2.3' 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.8'
ResponseHeaderBag.php Merge branch '2.5' into 2.6
ServerBag.php Handled bearer authorization header in REDIRECT_ form
StreamedResponse.php fixes CS
composer.json Merge branch '2.8'
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.