symfony 2 : Namespace “Acme” does not contain any mapped entities

后端 未结 7 2373
醉酒成梦
醉酒成梦 2021-02-13 04:23

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 cat

7条回答
  •  旧时难觅i
    2021-02-13 04:53

    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.

提交回复
热议问题