|
%!s(int64=13) %!d(string=hai) anos | |
---|---|---|
.. | ||
File | %!s(int64=13) %!d(string=hai) anos | |
SessionStorage | %!s(int64=13) %!d(string=hai) anos | |
ApacheRequest.php | %!s(int64=13) %!d(string=hai) anos | |
Cookie.php | %!s(int64=13) %!d(string=hai) anos | |
FileBag.php | %!s(int64=13) %!d(string=hai) anos | |
HeaderBag.php | %!s(int64=14) %!d(string=hai) anos | |
LICENSE | %!s(int64=14) %!d(string=hai) anos | |
ParameterBag.php | %!s(int64=13) %!d(string=hai) anos | |
README.md | %!s(int64=13) %!d(string=hai) anos | |
RedirectResponse.php | %!s(int64=13) %!d(string=hai) anos | |
Request.php | %!s(int64=13) %!d(string=hai) anos | |
RequestMatcher.php | %!s(int64=13) %!d(string=hai) anos | |
RequestMatcherInterface.php | %!s(int64=14) %!d(string=hai) anos | |
Response.php | %!s(int64=13) %!d(string=hai) anos | |
ResponseHeaderBag.php | %!s(int64=13) %!d(string=hai) anos | |
ServerBag.php | %!s(int64=13) %!d(string=hai) anos | |
Session.php | %!s(int64=13) %!d(string=hai) anos | |
composer.json | %!s(int64=13) %!d(string=hai) anos |
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.
Unit tests:
https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/HttpFoundation