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/README.md

57 lines
1.4 KiB
Markdown
Raw Normal View History

HttpFoundation Component
========================
2011-12-18 13:18:13 +00:00
HttpFoundation defines an object-oriented layer for the HTTP specification.
2011-12-18 13:18:13 +00:00
It provides an abstraction for requests, responses, uploaded files, cookies,
sessions, ...
2011-12-18 13:18:13 +00:00
In this example, we get a Request object from the current PHP global
variables:
2014-09-26 11:51:50 +01:00
```php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
2011-12-18 13:18:13 +00:00
2014-09-26 11:51:50 +01:00
$request = Request::createFromGlobals();
echo $request->getPathInfo();
```
You can also create a Request directly -- that's interesting for unit testing:
2014-09-26 11:51:50 +01:00
```php
$request = Request::create('/?foo=bar', 'GET');
echo $request->getPathInfo();
```
And here is how to create and send a Response:
2014-09-26 11:51:50 +01:00
```php
$response = new Response('Not Found', 404, array('Content-Type' => 'text/plain'));
$response->send();
```
2011-12-18 13:18:13 +00:00
The Request and the Response classes have many other methods that implement
the HTTP specification.
2012-02-16 02:49:09 +00:00
Loading
-------
If you are not using Composer but are using PHP 5.3.x, you must add the following to your autoloader:
2012-02-16 02:49:09 +00:00
2014-09-26 11:51:50 +01:00
```php
// SessionHandlerInterface
if (!interface_exists('SessionHandlerInterface')) {
$loader->registerPrefixFallback(__DIR__.'/../vendor/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs');
}
```
2012-02-16 02:49:09 +00:00
Resources
---------
2012-03-31 14:56:35 +01:00
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/HttpFoundation/
$ composer.phar install
$ phpunit