0
votes

I create project from Symfony 2, but I have a problem: In project have multi-bundles(ex: AdminBundle and FontEndBundle)

  1. Case 1: Doctrine orm and Entities generate on FrontEndBundle, then from AdminBundle, I will call Entity via FrontEndBundle:Object it work OK.
  2. Case 2: I want to config structure folow

    src/Project/

    • Model/Entity
    • OrmYml/doctrine/orm
    • Bundles(contains FontEndBundle & AdminBundle)
    • Extensions

In case 2, How do I config Entity mapping to generate Entities to src/Model/Entity directory ? Because when I using Command: doctrine:generate:entities Project/Model/Entity,

error : Namespace "Project\Model\Entity" does not contain any mapped entities.

2

2 Answers

0
votes

How do you declare your entities ?You should put your entities within a bundle. You cant have them outside a bundle .

0
votes

Usually, Symfony developpers create a third bundle called "CoreBundle" (for example) where you place all the shared resource between your three bundles, namely the entities, some services (like twig extensions), config (with service.xml/yml), ... Also, you can delete the controller and views directories in this bundles, which are useless (don't forget to clean the app/config/routing.yml file by removing the CoreBundle controller injection) !

Then just call your entities in the right bundle with:

use MyName\Bundle\CoreBundle\Entity\MyEntity;

Never create a model repertory not in a bundle, this is not the Symfony philosophy and you are really wrong !