|
|
пре 7 година | |
|---|---|---|
| .. | ||
| File | пре 7 година | |
| Session | пре 7 година | |
| Tests | пре 7 година | |
| .gitignore | пре 7 година | |
| AcceptHeader.php | пре 7 година | |
| AcceptHeaderItem.php | пре 7 година | |
| ApacheRequest.php | пре 7 година | |
| BinaryFileResponse.php | пре 7 година | |
| CHANGELOG.md | пре 7 година | |
| Cookie.php | пре 7 година | |
| ExpressionRequestMatcher.php | пре 7 година | |
| FileBag.php | пре 7 година | |
| HeaderBag.php | пре 7 година | |
| IpUtils.php | пре 7 година | |
| JsonResponse.php | пре 7 година | |
| LICENSE | пре 7 година | |
| ParameterBag.php | пре 7 година | |
| README.md | пре 7 година | |
| RedirectResponse.php | пре 7 година | |
| Request.php | пре 7 година | |
| RequestMatcher.php | пре 7 година | |
| RequestMatcherInterface.php | пре 7 година | |
| RequestStack.php | пре 7 година | |
| Response.php | пре 7 година | |
| ResponseHeaderBag.php | пре 7 година | |
| ServerBag.php | пре 7 година | |
| StreamedResponse.php | пре 7 година | |
| composer.json | пре 7 година | |
| phpunit.xml.dist | пре 7 година | |
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.
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/HttpFoundation/
$ composer install
$ phpunit