title: Symfony 4, how get the root path directory (or /src path) properly from a Service Class ? ( error : 'Call to a member function get() on null')
body: <p>In Symfony 4, from a controller I can get the root path of my project via : </p>
  
  <pre><code>// From a Controller Class, in the src/Controller dir
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  // ...
  Class myController extends Controller{
  // ...
  // in a public method
  $rootDir = $this-&gt;get('kernel')-&gt;getRootDir();
  </code></pre>
  
  <p>But how can I get the root path from a Service Class ? 
  I tried this (ugly) way </p>
  
  <pre><code>// From a Service Class, in the src/Service dir
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  // ...
  Class myService extends Controller{
  // ...
  // in a public method
  $rootDir = $this-&gt;get('kernel')-&gt;getRootDir();
  </code></pre>
  
  <p>But when I did that, I get the error : </p>
  
  <pre><code>"Call to a member function get() on null"
  </code></pre>
  
  <p>Why this solution does not work? </p>