Search code examples
symfonyentities

Symfony2 generate entities error


I'm trying to generate entities from existing tables in database, I keep getting the same error in a particular entity, which is imported from a second database (or entity manager), but I re-created this table in main database to use the same entity manager and get the same error, so I'm lost about what is happening.

This are my commands to generate it:

php app/console doctrine:mapping:convert yml ./src/MyShop/ProductBundle/Resources/config/doctrine/metadata/orm --from-database --filter="Product" --em=mysecondaryem

(BTW, is there a way to force exact filter? I only need Product) Which seems to be ok:

Processing entity "ProductSold"
Processing entity "Product"

Exporting "yml" mapping information to...

Then

php app/console doctrine:mapping:import MyShopProductBundle annotation --em=mysecondaryem

Which is weird, as it is logging information about all other tables existing in this db but it's only generating the corresponding to "Product" as filtered (only the files ProductSold.php and Product.php do really exist):

Importing mapping information from "mysecondaryem" entity manager
  > writing C:\mysite\src\MyShop\ProductBundle/Entity/ProductSold.php
  > writing C:\mysite\src\MyShop\ProductBundle/Entity/Family.php
  > writing C:\mysite\src\MyShop\ProductBundle/Entity/Category.php
  > writing C:\mysite\src\MyShop\ProductBundle/Entity/Item.php
  > writing C:\mysite\src\MyShop\ProductBundle/Entity/Stock.php
  > writing C:\mysite\src\MyShop\ProductBundle/Entity/Product.php

Then, in the third step, I get an error:

php app/console doctrine:generate:entities MyShopProductBundle --no-backup

Generating entities for bundle "MyShopProductBundle"
  [RuntimeException]
  Bundle "MyShopProductBundle" does not contain any mapped entities.
doctrine:generate:entities [--path="..."] [--no-backup] name

As I sayed, I tried omitting secondary entity manager (replicating tables in my first database) and I get the same error.


Solution

  • Ok, I found the error, I was missing --force parameter, first step command should be:

    php app/console doctrine:mapping:convert yml ./src/MyShop/ProductBundle/Resources/config/doctrine/metadata/orm --from-database --force --filter="Product" --em=mysecondaryem