title: Symfony2: how to set the host/base url in CLI scripts
body: <p>I'm currently writing a newsletter tool, and therefore have to generate absolute URLs in a CLI script which is called via cron.</p>
  
  <p>Unfortunately the Symfony CLI command does not know anything about my host/base_url, so the router generates absolute URLs with a wrong base_url. It always uses <code>http://localhost</code> as base.</p>
  
  <p>Is there a way to tell the router the correct base_url?</p>
  
  <p>My code:</p>
  
  <pre><code>$this-&gt;container-&gt;get('router')-&gt;generate($route, $parameters, true);
  </code></pre>