Skip to content
[READ-ONLY] Subtree split of the Symfony HttpFoundation Component
Latest commit 6edfe4a @nicolas-grekas nicolas-grekas Merge branch '3.0'
* 3.0: (105 commits)
  [Console] remove readline support
  bumped Symfony version to 3.0.3
  updated VERSION for 3.0.2
  updated CHANGELOG for 3.0.2
  [Routing] added a suggestion to add the HttpFoundation component.
  [FrameworkBundle] fix assets and templating tests
  [ClassLoader] fix ApcClassLoader tests on HHVM
  [travis] Add some comments
  changed operator from and to &&
  [DependencyInjection] Remove unused parameter
  [Process] Fix transient tests for incremental outputs
  [Console] Add missing `@require` annotation in test
  Fix merge
  [appveyor] Fix failure reporting
  [#17634] move DebugBundle license file
  Limit Ldap component version for the 3.0 branch
  backport GlobTest from 2.7 branch
  Move licenses according to new best practices
  [FrameworkBundle] Remove unused code in test
  [2.3] Fixed an undefined variable in Glob::toRegex

Failed to load latest commit information.
File Merge branch '2.3' into 2.7
Session Merge branch '2.8' into 3.0
Tests Merge branch '3.0'
.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.7 [HttpFoundation] change precedence of parameters in Request::get
Cookie.php [HttpFoundation][Cookie] Cookie DateTimeInterface fix
ExpressionRequestMatcher.php [HttpFoundation] added ExpressionRequestMatcher
FileBag.php remove api tags from code
HeaderBag.php Merge branch '2.3' into 2.7
IpUtils.php [HttpFoundation] Fixes /0 subnet handling in IpUtils
JsonResponse.php Remove code for PHP <5.5.9
LICENSE Update copyright year
ParameterBag.php [HttpFoundation] Remove deprecated class method parameter Rely on iconv and symfony/polyfill-*
RedirectResponse.php remove api tags from code
Request.php Merge branch '3.0'
RequestMatcher.php Merge branch '2.3' into 2.7
RequestMatcherInterface.php remove api tags from code
RequestStack.php unified return null usages
Response.php Merge branch '2.8' into 3.0
ResponseHeaderBag.php Merge branch '2.3' into 2.7
ServerBag.php [HttpFoundation] Do not overwrite the Authorization header if it is a…
StreamedResponse.php Add more callable type hints
composer.json updated version to 3.1
phpunit.xml.dist Add missing exclusions from phpunit.xml.dist

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.


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.