I am following the book and on the page http://symfony.com/doc/current/book/doctrine.html
While following the book I am trying to work on relationship of product and category table and doctrine generate command is giving me following error.
php app/console doctrine:generate:entities Acme
Generating entities for namespace "Acme"
[RuntimeException]
Namespace "Acme" does not contain any mapped entities.
doctrine:generate:entities [--path="..."] [--no-backup] name
Thx
With
doctrine:generate:entity
you'll create new entity.
And when you add some attributes by hand with
doctrine:generate:entities AcmeDemoBundle:User
you'll create all accessor (getter and setter) of the entity User of AcmeDemoBundle
This error will also come up if your projects (only?) Entity is namespaced incorrectly. If you run the command
$ php app/console doctrine:generate:entities MyBundle
and it produces the error
[RuntimeException]
Bundle "MyBundle" does not contain any mapped entities.
Check the more specific command....
$ php app/console doctrine:generate:entities MyBundle:MyEntity
And see if you get the error:
[RuntimeException]
The autoloader expected class "MyBundle\Entity\MyEntity" to be defined in file "/path/to/MyBundle/Entity/MyEntity.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
If so, well then, the error speaks for itself (hopefully) and the namespace/class name needs to be corrected. Hopefully that is helpful to someone.
The solution:
Update symfony files:
composer update
then create entities
php bin/console doctrine:generate:entities BackendBundle
Check that the PHP opening and (optional) closing tags
<?php
and
?>
are correct in your file.
They are not included when you copy paste from the tutorial at http://symfony.com/doc/current/book/doctrine.html
I was stuck at the same problem. After looking at this post I started wondering why the syntax highlighting was broken and discovered that the opening and closing tags were missing. The error disappeared when the tags were included.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With