How to get the full url for an asset in Controller?

You can generate the url from the request object:

$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();

You could make a twig extension that cuts the /web part of your path and uses the request to generate the base url.

see Symfony\Component\Routing\Generator\UrlGenerator::doGenerate for a more solid implementation.

Also, Twig has access to the request from app.request.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)