7
votes

Does anybody know how to get the current URI in a Twig template?

I’ve read through the documentation and I’m unable to find the Twig function to do this.

1

1 Answers

15
votes
{{ app.request.uri }}

If you want to read it into a view variable:

{% set uri = app.request.uri %}

The app global view variable contains all sorts of useful shortcuts, such as app.session and app.security.token.user, that reference the services you might use in a controller.