I just started my first project with composer and wanted to set up the database and the classes for it. However I'm stuck. I'm getting the above error in the prod.log
I followed this tutorial here: http://symfony.com/doc/current/book/doctrine.html
I created the database
php bin/console doctrine:database:create
then wanted to create an entity
php bin/console doctrine:generate:entity
When asked for the The Entity shortcut name I entered AppBundle:Product
and then created the database fields etc.
And I'm getting this message
Entity generation
Generating entity class src/AppBundle/Entity/Product.php: OK!
Generating repository class src/AppBundle/Repository/ProductRepository.php: OK!Everything is OK! Now get to work :).
So this sounds like everything worked, right?
Now in my ProductController I used this
$products = $this->getDoctrine()
->getRepository('AppBundle:Product')
->findAll();
and I'm getting the error
[2016-02-15 18:56:14] request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\ORMException: "Unknown Entity namespace alias 'AppBundle'." at /home/vagrant/work/homestead/test/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php line 271 {"exception":"[object] (Doctrine\\ORM\\ORMException(code: 0): Unknown Entity namespace alias 'AppBundle'. at /home/vagrant/work/homestead/test/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php:271)"} []
I also tried
->getRepository('AppBundle\Entity\Product')
but here I'm getting the message
[2016-02-15 19:01:39] request.CRITICAL: Uncaught PHP Exception Doctrine\Common\Persistence\Mapping\MappingException: "The class 'AppBundle\Entity\Product' was not found in the chain configured namespaces " at /home/vagrant/work/homestead/test/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php line 37 {"exception":"[object] (Doctrine\\Common\\Persistence\\Mapping\\MappingException(code: 0): The class 'AppBundle\\Entity\\Product' was not found in the chain configured namespaces at /home/vagrant/work/homestead/test/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php:37)"} []
How do I actually get this to work/ I just started with the project. Doctrine created the classes though. I have it like this
/src
/src/AppBundle/
/src/AppBundle/Entity
Product.php
/src/AppBundle/Repository
ProductRepository.php
Also, in the Product.php this is in the comments of the annotations (if it helps)
* @ORM\Entity(repositoryClass="AppBundle\Repository\ProductRepository")
Also, when trying this command php bin/console doctrine:generate:entities AppBundle to recreate the entities I'm getting no error message.
I'm getting
Generating entities for bundle "AppBundle"
> backing up Product.php to Product.php~
> generating AppBundle\Entity\Product
AppBundle/Resources. I always selectedannotationswhen creating the entities, so there shouldn't be any configs, right? No, I made no changes in theapp/config/config.ymlphp bin/console doctrine:schema:update --force. Than check yournamespaceinControllermust beAppBundle\Entity\Product.