This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/HttpFoundation
Fabien Potencier d9959af406 merged branch Seldaek/composer_alias (PR #3457)
Commits
-------

bafcaaf Removed version field
f9d9dc7 Add branch-alias for composer

Discussion
----------

Add branch-alias for composer

This should restore the 2.1-dev version (as an alias of dev-master) so that `2.*` or `2.1.*` constraints work again. I'll adjust packagist soon to also display those aliases.
2012-02-27 10:07:31 +01:00
..
File Added support for SVG mime type 2012-02-14 11:06:36 +00:00
Resources/stubs [HttpFoundation] Added forward compatibility for \SessionHandlerInterface 2012-02-22 07:07:07 +05:45
Session Removed useless parameter from Memcached::set() 2012-02-25 17:34:02 +02:00
ApacheRequest.php [HttpFoundation] fixed ApacheRequest 2011-12-21 13:57:56 -08:00
composer.json Removed version field 2012-02-27 09:59:20 +01:00
Cookie.php [HttpFoundation] Cookie values should not be restricted 2011-11-23 11:38:46 +01:00
FileBag.php [DoctrineBridge] fixed some CS 2011-12-13 10:22:12 +01:00
HeaderBag.php [HttpFoundation] tagged public @api 2011-07-20 10:06:02 +02:00
LICENSE Updated LICENSE files copyright 2012-02-22 10:10:37 +01:00
ParameterBag.php merged 2.0 2011-12-26 21:57:48 +01:00
README.md [HttpFoundation] Documentation. 2012-02-22 07:07:11 +05:45
RedirectResponse.php [HttpFoundation] RedirectResponse: add the ability to retrieve the target URL, add unit tests 2012-02-06 19:09:24 +01:00
Request.php [HttpFoundation] fixed Request::create() when passing arguments as an array (closes #3314) 2012-02-12 00:26:10 +01:00
RequestMatcher.php fixed CS 2011-12-18 14:36:25 +01:00
RequestMatcherInterface.php [HttpFoundation] tagged public @api 2011-07-20 10:06:02 +02:00
Response.php merged 2.0 2012-02-22 18:59:56 +01:00
ResponseHeaderBag.php fixed CS 2011-12-18 14:36:25 +01:00
ServerBag.php merged 2.0 2012-01-16 07:44:08 +01:00
StreamedResponse.php [streaming] Do not set a Transfer-Encoding header of chunked 2012-01-02 19:50:39 +01:00

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 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

Unit tests:

https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/HttpFoundation