I'm using absolute_url function defined here in my twig email template that is triggered via symfony command but the path only returns localhost/route instead of the complete URL http://abc.local/route.
<a href="{{ absolute_url('downloads') }}">download</a>
What am I missing here ?
Solution with Symfony-5.4
Generating URLs in commands works the same as generating URLs in services. The only difference is that commands are not executed in the HTTP context. Therefore, if you generate absolute URLs, you'll get
http://localhost/as the host name instead of your real host name.The solution is to configure the
default_urioption to define the "request context" used by commands when they generate URLs: On config/packages/routing.yaml add the URL of the real host.For reference please see the official documentation. https://symfony.com/doc/5.4/routing.html#generating-urls-in-commands