getting route name not the route path in twig symfony

33,058

This is because you put the path function try like this

{% set current_path = app.request.get('_route') %}
{{ current_path }}
Share:
33,058
walidtlili
Author by

walidtlili

I love coding

Updated on July 23, 2022

Comments

  • walidtlili
    walidtlili almost 2 years

    i'm developing an application with symfony3.
    I want to get route name in twig. i did this :

     {% set current_path = path(app.request.get('_route')) %}
     {{ current_path }}
    

    it displays the url of the current page. But i want to get route name not the path. example :

    personnel_index:
        path:     /liste
        defaults: { _controller: "PersonnelBundle:Personnel:index" }
        methods:  GET
    

    must return : personnel_index

    so how can i get the route name