I would like to pass a variable to my controller and I need to get its value regardless of its request method (POST or GET), the equivalent of $_REQUEST['myvar'], how do I do this?
To get url attribute which is a part of a route you have to do something like this (in controller):
$request->attributes->get(<attribute_name>);
If you need to get POST or GET parameter you have to use this code:
$request->get(<parameter_name>);
If you need to get value of $_SERVER array you have to do this:
$request->server->get(<server_key_name>); //$request->server->get('HTTP_REFERER');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With