Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

This branch is 182 commits ahead, 42 commits behind 2.7

Merge branch '2.7'

* 2.7: (55 commits)
  CS: fix some license headers
  CS: Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline
  Improve triggering of the deprecation error
  [SecurityBundle] Fix typos in LogoutUrlHelper
  [VarDumper] add caster for MongoCursor objects
  make it possible to dump inlined services to XML
  [VarDumper] Fixed notice when Exchange is mocked
  [Translation] keep old array structure of resourcesFiles to avoid BC.
  removed deprecated notices that make the tests fail
  use visited lookup with reference to gain performance
  [VarDumper] with-er interface for Cloner\Data
  Replace GET parameters when changed
  tweaked phpdocs
  [Process] Fix outdated Process->start() docblock
  prevent inlining service configurators
  Improve entropy of generated salt
  Complete the removal of API versions in the validator component
  [Validator] deprecated API version
  Removed 2.5 bc layer
  [SecurityBundle] UserPasswordEncoderCommand: fix help arguments order.

latest commit 9fe9832049
@fabpot fabpot authored
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 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 CS: Convert double quotes to single quotes
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 RequestMatcher
RequestMatcherInterface.php Docblock fixes
RequestStack.php unified return null usages
Response.php Merge branch '2.3' into 2.6
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.