How do I get the $ _REQUEST variable?
2 answers
To get the url attribute that is part of the route, you need to do something like this (in the controller):
$request->attributes->get(<attribute_name>);
If you need to get POST or GET parameter, you should use this code:
$request->get(<parameter_name>);
If you need to get the value of the $ _SERVER array, you should do this:
$request->server->get(<server_key_name>); //$request->server->get('HTTP_REFERER');
+5
source to share
I found the answer ... Instead of using one of the following:
public function indexAction(Request $request)
{
$request->query->get('myvar'); //gets GET var.
$request->request->get('myvar'); //gets POST var.
...
I need to call get in class Request
public function indexAction(Request $request)
{
$myvar = $request->get('myvar', null);
...
0
source to share