Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current absolute url in twig without rendering route?

Tags:

twig

symfony

In twig I need to get the current full uri (url + uri ) without render it it like

path('route_test', {param1:1})

How to get it ?

like image 334
smartius Avatar asked Feb 01 '13 12:02

smartius


People also ask

How do I create a route in twig?

You can get the current URL in Twig/Silex 2 like this: global. request. attributes. get('_route') .


2 Answers

Try to use :

{{ app.request.uri }}
like image 77
Pierrickouw Avatar answered Oct 31 '22 13:10

Pierrickouw


As it was said above, some of the answers are not valid anymore.

What worked for me as of 2017'09 is this

{{ url('<current>') }}
like image 29
Larzan Avatar answered Oct 31 '22 13:10

Larzan