title: How to get the server path to the web directory in Symfony2 from inside the controller?
body: <p>The question is as follows:</p>
  
  <p>How can I get the server path to the web directory in Symfony2 from inside the controller (or from anywhere else for that reason)</p>
  
  <p>What I've already found (also, by searching here):</p>
  
  <p>This is advised in the cookbook article on Doctrine file handling</p>
  
  <pre><code>$path = __DIR__ . '/../../../../web';
  </code></pre>
  
  <p>Found by searching around, only usable from inside the controller (or service with kernel injected):</p>
  
  <pre><code>$path = $this-&gt;get('kernel')-&gt;getRootDir() . '/../web';
  </code></pre>
  
  <p>So, is there absolutely no way to get at least that 'web' part of the path? What if I, for example, decided to rename it or move or something?</p>
  
  <p>Everything was easy in the first symfony, when I could get like everything I needed from anywhere in the code by calling the static sfConfig::get() method..</p>