How to get current route in Symfony 2? How to get current route in Symfony 2? symfony symfony

How to get current route in Symfony 2?


From something that is ContainerAware (like a controller):

$request = $this->container->get('request');$routeName = $request->get('_route');


With Twig : {{ app.request.attributes.get('_route') }}


I think this is the easiest way to do this:

class MyController extends Controller{    public function myAction($_route)    {        var_dump($_route);    }    .....