symfony get url of a relative path.

in controller:
$this->getRequest()->getUriForPath('/uploads/myimage.jpg');
in twig:
{{ app.request.uriForPath('/uploads/myimage.jpg') }}
or 

{{  asset('/uploads/myimage.jpg')}} 

评论

热门博文