title: Unknown Entity namespace alias 'Appbundle'
body: <p>I have just started my first symfony project and I'm getting the above error in a more complex situation. To narrow it down I created a new project but the error is there again :/ </p>
  
  <p>What I have down:</p>
  
  <blockquote>
    <p>cd /var/www</p>
    
    <p>sudo symfony new em</p>
    
    <p>cd em</p>
    
    <p>sudo mkdir src/AppBundle/Entity</p>
    
    <p>sudo touch src/AppBundle/Entity/Company.php</p>
    
    <p>sudo chmod -R 777 *</p>
    
    <p>php bin/console doctrine:database:create  // db symfony</p>
    
    <p>php bin/console doctrine:generate:entities AppBundle</p>
    
    <p>sudo touch src/AppBundle/Controller/CompanyController.php</p>
    
    <p>sudo chmod -R 777 * // failed to write to cache</p>
  </blockquote>
  
  <p>When navigating to <a href="http://em.at/app_dev.php/companies" rel="nofollow noreferrer">http://em.at/app_dev.php/companies</a> I get the error!</p>
  
  <p>I already tried <a href="https://stackoverflow.com/questions/35417149/uncaught-php-exception-doctrine-orm-ormexception-unknown-entity-namespace-alia">Uncaught PHP Exception Doctrine\ORM\ORMException: &quot;Unknown Entity namespace alias &#39;AppBundle&#39;.&quot;</a></p>
  
  <p>so </p>
  
  <blockquote>
    <p>php bin/console cache:clear </p>
  </blockquote>
  
  <p>which resulted in </p>
  
  <blockquote>
    <p>[Symfony\Component\Filesystem\Exception\IOException]<br>
      Failed to remove file    "/var/www/em/var/cache/de~/twig/2b/2bef18b12bca6cd9cb<br>
      d50ce5b194c23fdc85bb73d29114f27fb3793b7f085d8a.php": . </p>
  </blockquote>
  
  <p>so I deleted them manually </p>
  
  <blockquote>
    <p>sudo rm -R cache/de~</p>
    
    <p>sudo rm -R cache/dev</p>
  </blockquote>
  
  <p>but the error persists. Anyone know what's wrong?.</p>
  
  <p>my files:</p>
  
  <pre><code>&lt;?php
  // src/AppBundle/Entity/Company.php
  namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="company")
   */
  class Company
  {
      /**
       * @ORM\Column(type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=100)
       */
      private $name;
  
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>&lt;?php
  // src/AppBundle/Entity/CompanyController.php
  namespace AppBundle\Controller;
  
  use AppBundle\Entity\Company;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\HttpFoundation\Request;
  
  class CompanyController extends Controller
  {
      /**
       * @Route("/companies", name="company_list")
       */
      public function listAction(Request $request)
      {
          $companies = $this-&gt;getDoctrine()-&gt;getRepository('Appbundle:Company')-&gt;findAll();
          // replace this example code with whatever you need
          return $this-&gt;render('company/list.html.twig', [
              'base_dir' =&gt; realpath($this-&gt;getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
              'companies' =&gt; $companies
          ]);
      }
  
  }
  </code></pre>