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 539634cbaa merged 2.0
2012-04-20 12:18:51 +02:00
..
File Fix umasks in chmod() calls 2012-04-19 15:47:04 +02:00
Resources/stubs [HttpFoundation] Documentation. 2012-03-01 07:19:15 +05:45
Session Use Memcache::replace() first instead of Memcache::set(): http://docs.php.net/manual/en/memcache.replace.php#100023 2012-04-18 12:17:02 +02:00
Tests [Routing] Request methods always return a raw path, fix the matcher to decode only once 2012-04-10 10:40:58 +02:00
ApacheRequest.php [HttpFoundation] fixed ApacheRequest 2011-12-21 13:57:56 -08:00
composer.json fixed typos in composer file 2012-03-15 11:15:25 +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\HeaderBag Little improvement. 2012-03-24 11:17:54 +04:00
JsonResponse.php fixed CS 2012-03-23 14:14:07 +01:00
LICENSE Updated LICENSE files copyright 2012-02-22 10:10:37 +01:00
ParameterBag.php merged 2.0 2012-04-20 12:18:51 +02:00
phpunit.xml.dist [PhpUnit] Fix the path to the boostrap files in the components 2012-03-30 13:49:28 +02:00
README.md updated reference to tests 2012-03-31 15:56:35 +02:00
RedirectResponse.php merged branch Seldaek/chainableresp (PR #3606) 2012-03-15 19:10:35 +01:00
Request.php [Routing] Request methods always return a raw path, fix the matcher to decode only once 2012-04-10 10:40:58 +02:00
RequestMatcher.php [Routing] Request methods always return a raw path, fix the matcher to decode only once 2012-04-10 10:40:58 +02:00
RequestMatcherInterface.php [HttpFoundation] tagged public @api 2011-07-20 10:06:02 +02:00
Response.php Fix typo: Resonse -> Response 2012-04-18 13:38:08 -07:00
ResponseHeaderBag.php fixed CS 2011-12-18 14:36:25 +01:00
ServerBag.php merged 2.0 2012-04-06 14:21:18 +02:00
StreamedResponse.php Return from Response::prepare() so that the method may be chained. 2012-04-16 19:22:20 -05: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

You can run the unit tests with the following command:

phpunit -c src/Symfony/Component/HttpFoundation/