Examples below are useful tips for us to benefit from in twig templates.


Print namespace and current method


{{ app.request.attributes.get("_controller") }}

# Output
Football\FrontendBundle\Controller\DefaultController::indexAction

Print router name


{{ app.request.attributes.get('_route') }}

# Output
football_frontend_homepage

Print router parameters


{{ dump(app.request.attributes.get('_route_params')) }}

# Output - Assuming that the URI is http://sport.local/app_dev.php/inanzzz
array:1 [
"name" => "inanzzz"
]

Print query string parameters


# URL
app_test.php/emails?type=delivered&from_date=26-02-2015&to_date=26-02-2016&limit=25&keyword=

{{ dump(app.request.query.all) }}

# Output
array:5 [
"type" => "delivered"
"from_date" => "26-02-2015"
"to_date" => "26-02-2016"
"limit" => "25"
"keyword" => ""
]