title: How to use my Entities and Entity Managers in Symfony 2 Console Command?
body: <p>I want to a few terminal commands to my Symfony2 application. I've gone through the <a href="http://symfony.com/doc/2.0/cookbook/console.html">example in the cookbook</a>, but I couldn't find out how to access my settings, my entity manager and my entities here. In the constructor, I get the container (which should yield me access to settings and entities) using</p>
  
  <pre><code>$this-&gt;container = $this-&gt;getContainer();
  </code></pre>
  
  <p>But this call generates an error:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function getKernel() on a non-object in /Users/fester/Sites/thinkblue/admintool/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php on line 38</p>
  </blockquote>
  
  <p>Basically, in ContainerAwareCommand->getContainer() the call to</p>
  
  <pre><code>$this-&gt;getApplication()
  </code></pre>
  
  <p>returns NULL and not an object as expected. I guess that I left some important step out, but which one? And how will I finally be able to use my settings and entities?</p>