Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
[READ-ONLY] Subtree split of the Symfony HttpFoundation Component -- clone into Symfony/Component/ (master at symfony/symfony)
PHP
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 Merge branch '2.3' into 2.6
CHANGELOG.md [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
README.md 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 Remove code for PHP <5.5.9
ResponseHeaderBag.php Merge branch '2.5' into 2.6
ServerBag.php Handled bearer authorization header in REDIRECT_ form
StreamedResponse.php [HttpFoundation] Allow Cache-Control headers on StreamedResponse
composer.json Merge branch '2.8'
phpunit.xml.dist [PhpUnitBridge] new bridge for testing with PHPUnit

README.md

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'));
$response->send();

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

Loading

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')) {
    $loader->registerPrefixFallback(__DIR__.'/../vendor/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs');
}

Resources

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.