symfony 2 : Namespace "Acme" does not contain any mapped entities

Viewed 36011

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

7 Answers

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

I personally had the error because I was missing the folder/directory "Entity".

Related