<p dir="auto">Since 2.7, it's recommended to use <code class="notranslate">absolute_url</code> to generate absolute assets URL (<a href="http://symfony.com/blog/new-in-symfony-2-7-the-new-asset-component" rel="nofollow">http://symfony.com/blog/new-in-symfony-2-7-the-new-asset-component</a>).</p>
<p dir="auto">However, in a console command, <code class="notranslate">absolute_url</code> does not rely on <code class="notranslate">request_context</code> and, therefore, cannot generate reliable asset URLs...</p>
<p dir="auto"><strong>Reproduction</strong>:</p>
<p dir="auto">Clone: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/lemoinem/symfony-standard/commit/c5bcfb4/hovercard" href="https://github.com/lemoinem/symfony-standard/commit/c5bcfb4">lemoinem/symfony-standard@<tt>c5bcfb4</tt></a> (branch: <code class="notranslate">bug/absolute-url-in-command</code>)<br>
(No DB, nor mailer config required)</p>
<p dir="auto">Command: <code class="notranslate">php app/console TEST:absolute-url</code></p>
<p dir="auto">Hi,</p>
<p dir="auto">I m trying to send emails from the CLI (with a valid scheme/host)</p>
<ul dir="auto">
<li>For the <code class="notranslate">{{ url('app_homepage') }}</code> =&gt; it works (cf <a href="http://symfony.com/doc/current/cookbook/console/sending_emails.html#configuring-the-request-context-per-command" rel="nofollow">http://symfony.com/doc/current/cookbook/console/sending_emails.html#configuring-the-request-context-per-command</a>)</li>
<li>For the <code class="notranslate">{{ absolute_url(asset('img/app.jpg')) }}</code> =&gt; does not work</li>
</ul>
<p dir="auto">Is this a bug or I should use a different way to succeed ?</p>
<p dir="auto">Many thanks for your answers,</p>
<p dir="auto">Cheers,</p>