1use Symfony\Component\HttpFoundation\Request;
2
3$request = Request::createFromGlobals();
4
5// the URI being requested (e.g. /about) minus any query parameters
6$request->getPathInfo();
7
8// retrieves $_GET and $_POST variables respectively
9$request->query->get('id');
10$request->request->get('category', 'default category');
11
12// retrieves $_SERVER variables
13$request->server->get('HTTP_HOST');
14
15// retrieves an instance of UploadedFile identified by "attachment"
16$request->files->get('attachment');
17
18// retrieves a $_COOKIE value
19$request->cookies->get('PHPSESSID');
20
21// retrieves an HTTP request header, with normalized, lowercase keys
22$request->headers->get('host');
23$request->headers->get('content-type');
24
25$request->getMethod(); // e.g. GET, POST, PUT, DELETE or HEAD
26$request->getLanguages(); // an array of languages the client accepts
27