title: Symfony2: How to set the root path in a Symfony CLI  command
body: <p>EDIT:
  to cut this short: is there a way to call $kernel->getRootDir(); from within a twig extension? Or maybe from the DI container?</p>
  
  <p>ORIGINAL QUESTION:</p>
  
  <p>I try to scale images on the server by using Imagine. Everything works fine as log as I don't try to trigger the rendering via command line:
  In this case it looks like there is a wrong path set- I'm getting an error:</p>
  
  <p>[Twig_Error_Runtime]                                                                                           </p>
  
  <blockquote>
    <p>An exception has been thrown during the rendering of a template
    ("File ../web/documents/4f59ef3f76e74_test3.jpg doesn't exist") in
    "....:detail.html.twig" at line 72.</p>
  </blockquote>
  
  <p>I'm using a twig tag which I wrote by myself:</p>
  
  <pre><code> public function thumbnail($path,$width,$maxHeight=0,$alt="",$absolute=false){
  
          /* @var $imagine \Imagine\Gd\Imagine */
          $imagine = $this-&gt;container-&gt;get('imagine');
  
          //$box = new \Imagine\Image\Box($width, $height);
  
          /* @var $image \Imagine\Image\ImageInterface */
          $image = $imagine-&gt;open("../web/".$path);
  ...
  </code></pre>
  
  <p>I also tried this (both works when I render the template via browser request)</p>
  
  <pre><code>$image = $imagine-&gt;open($path);
  </code></pre>
  
  <p>$path is set to "documents/4f59ef3f76e74_test3.jpg"
  "documents/" is a sub directory of "web"</p>
  
  <p>Any ideas?</p>