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
2012-07-01 23:25:00 +02:00
..
File [HttpFoundation] CS and phpdoc fixes 2012-06-25 18:21:41 +02:00
Resources/stubs Fixes typos 2012-04-28 00:51:32 -03:00
Session fixed previous merge 2012-07-01 23:25:00 +02:00
Tests fixed previous merge 2012-07-01 23:25:00 +02:00
ApacheRequest.php [HttpFoundation] fixed ApacheRequest 2011-12-21 13:57:56 -08:00
CHANGELOG.md added Request::getSchemeAndHttpHost() and Request::getUserInfo() (closes #4312, refs #3416, refs #3056) 2012-06-28 17:56:04 +02:00
composer.json updated minimum PHP version to 5.3.3 2012-05-07 10:29:11 +02:00
Cookie.php [HttpFoundation] CS and phpdoc fixes 2012-06-25 18:21:41 +02:00
FileBag.php [HttpFoundation] CS and phpdoc fixes 2012-06-25 18:21:41 +02:00
HeaderBag.php fixed phpdoc @param alignment 2012-05-15 22:19:31 +02:00
JsonResponse.php [HttpFoundation] Make JsonResponse HTML safe. 2012-06-07 17:39:19 +02:00
LICENSE Updated LICENSE files copyright 2012-02-22 10:10:37 +01:00
ParameterBag.php [HttpFoundation] CS and phpdoc fixes 2012-06-25 18:21:41 +02:00
phpunit.xml.dist [Components] Tests/Autoloading fixes 2012-05-01 17:51:41 +02:00
README.md [Components] Tests/Autoloading fixes 2012-05-01 17:51:41 +02:00
RedirectResponse.php merged branch Seldaek/chainableresp (PR #3606) 2012-03-15 19:10:35 +01:00
Request.php fixed previous merge 2012-07-01 23:25:00 +02:00
RequestMatcher.php [HttpFoundation] CS and phpdoc fixes 2012-06-25 18:21:41 +02:00
RequestMatcherInterface.php fixed phpdoc @param alignment 2012-05-15 22:19:31 +02:00
Response.php merged branch adrienbrault/http-foundation-fixes (PR #4483) 2012-06-25 22:29:10 +02:00
ResponseHeaderBag.php fixed CS 2011-12-18 14:36:25 +01:00
ServerBag.php merged 2.0 2012-06-20 21:33:33 +02:00
StreamedResponse.php [HttpFoundation] CS and phpdoc fixes 2012-06-25 18:21:41 +02: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