Php – Twig templates engine: get current url

PHPtwig

How can I get the current URL from a Twig template?

I am using Twig with PHP, without any other framework.

Best Answer

The following works in Silex and most certainly in Symfony2 as they share the Request class (I did not test though) :

{{ app.request.getRequestUri() }}