symfony Controllers Using data from the Request object


Example

If you need to access the Request object (for instance to read the query parameters, to read an HTTP header or to process an uploaded file), you can receive the request as a method argument by adding a type-hinted argument:

use Symfony\Component\HttpFoundation\Request;

public function indexAction(Request $request)
{
    $queryParam = $request->query->get('param');

    // ...
}

Symfony will recognize the type hint and add the request argument to the controller call.