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

后端 未结 7 2372
醉酒成梦
醉酒成梦 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条回答
  •  时光取名叫无心
    2021-02-13 04:41

    In book http://symfony.com/doc/current/book/doctrine.html entity Porduct has been manually created. You wrote code to Product.php. All information about entity fields contains in annotations.
    But entity Category has been created with

    php app/console doctrine:generate:entity --entity="AcmeStoreBundle:Category" --fields="name:string(255)"

    Automatically generated entity Caterory.php doesn't contains annotations. Symfony stored information in "Acme\StoreBundle\Resources\config\doctrine\Category.orm.yml". That's why php app/console doctrine:mapping:info says that you have only 1 mapped entity - Category.

    Solving
    You may generate Product entity with doctrine:generate:entity
    or
    Manually add information about Product entity to "Acme\StoreBundle\Resources\config\doctrine\Category.orm.yml"
    or
    Delete "Acme\StoreBundle\Resources\config\doctrine\Category.orm.yml" and describe Category entity with annotations in Category.php

提交回复
热议问题