Предположим пришел запрос: GET http://x.com:8000/app.php/path?foo=BAR
| $request-метод | Возвращает | Заметка |
|---|---|---|
| getUri() | http://x.com:8000/app.php/path?foo=BAR | |
| getRequestUri() | /app.php/path?foo=BAR | Удивительно, но переводит в верхний регистр символы полученные в результате применения функции urlencode(), при этом речь не идет о GET-переменных, речь просто части URL, например: /reason/%d0%94%d1%83%d0%b1%d0%bb%d1%8c будет возвращена как: /reason/%D0%94%D1%83%D0%B1%D0%BB%D1%8C похоже дело не в Symfony, дело либо в PHP, либо в Nginx, потому что нативными средствами получаемый URL имеет верхний регистр символов (хотя по факту используется нижний) |
| getBaseUrl() | /app.php/path | |
| getPathInfo() | /path | |
| getQueryString() | foo=BAR | |
| getHttpHost() | x.com:8000 | |
| getHost() | x.com | |
| getScheme() | http | |
| isSecure() | false | |
| getPort() | 8000 | |
| getUriForPath('/new?foo=BAR') | http://x.com:8000/app.php/new?foo=BAR | |
| getRelativeUriForPath('/new') | ../xxx | |
| getMethod | GET | |
| getRealMethod | GET | |
| getMimeType | null | |
| getContentType | null | |
| getContentTypeFormat | null | |
| getRequestFormat | html | |
| getDefaultLocale | en | |
| getLocale | en | |
| isMethodSafe | true | |
| isMethodIdempotent | true | |
| isMethodCacheable | true | |
| getProtocolVersion | HTTP/1.1 | |
| isXmlHttpRequest | false |
А другие виды запросов:
$request->query->get('foo'); // similar to $_GET['foo']
$request->request->get('foo'); // similar to $_POST['foo']
$request->cookies->get('foo'); // similar to $_COOKIES['foo']
$request->files->get('foo'); // similar to $_FILES['foo']А начиная с версии 6.3:
// the request has some POST data (e.g. `foo: bar` sent as `application/x-www-form-urlencoded`)
$request->getPayload()->all();
// returns the PHP array: ['foo' => 'bar']
// the request has body contents as some JSON-encoded data (e.g. `{"foo": "bar"}`)
$request->getPayload()->all();
// returns the JSON-decoded data as a PHP array: ['foo' => 'bar']
Комментарии
Комментариев пока нет.