Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a $_REQUEST variable?

Tags:

symfony

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?

like image 635
MikeGA Avatar asked Aug 26 '26 03:08

MikeGA


1 Answers

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');
like image 113
Alex Avatar answered Aug 27 '26 21:08

Alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!