title: Call to a member function has() on null 500 with Symfony and Doctrine
body: <p>I am having some trouble setting up doctrine to run from the following service file.</p>
  
  <pre><code>&lt;?php
  
  // src/AppBundle/Services/SuperusersService.php
  namespace AppBundle\Services;
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Doctrine\ORM\EntityManager;
  
  class SuperusersService extends Controller
  {
  
      public function sayHello()
      {
  
          $em = $this-&gt;getDoctrine()-&gt;getManager();
  
           // Query here
  
      }
  
  }
  </code></pre>
  
  <p>When I run the above I get the following error message.</p>
  
  <blockquote>
    <p>Call to a member function has() on null 500 Internal Server Error -
    FatalThrowableError</p>
  </blockquote>
  
  <p>I call the file from the following controller file.</p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Controller;
  
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\HttpFoundation\Request;
  
  class LoginController extends Controller
  {
      /**
       * @Route("/login")
       */
      public function indexAction(Request $request)
      {
  
          if(!empty($_POST)){
  
              ////
              // If for submitted attempt to log the user in.
              ////
  
              $superusersService = $this-&gt;get('app.superusers.services');
  
              $superusersService-&gt;sayHello();
  
          }
  
          $name = "Login";
  
          return $this-&gt;render('login/login.html.php', 
          array());
  
      }
  }
  </code></pre>
  
  <p>Service file</p>
  
  <pre><code># Learn more about services, parameters and containers at
  # http://symfony.com/doc/current/service_container.html
  parameters:
  #    parameter_name: value
  
  services:
  #    service_name:
  #        class: AppBundle\Directory\ClassName
  #        arguments: ["@another_service_name", "plain_value", "%parameter_name%"]
      app.superusers.services:
              class: AppBundle\Services\SuperusersService
  </code></pre>
  
  <p>Now I have taken a look around at other questions but as of yet I am unable to resolve the above. I think it will have something to do with the setup of the files but I'm not sure what.</p>