Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

doctrine:generate:crudでDoctrine\ORM\ORMException(Unknown Entity namespace)が発生する

自分用メモ。
新しいbundleにEntityクラスを追加し、以下のようにdoctrine:generate:crudを実行すると

$ php app/console doctrine:generate:crud --entity=AcmeSampleBundle:Sample --route-prefix=somewhere --with-write --no-interaction

[Doctrine\ORM\ORMException]
Unknown Entity namespace alias 'AcmeSampleBundle'.

$ 

という具合にDoctrine\ORM\ORMExceptionが発生する場合、app/config/config.ymlのdoctrine.orm.entity_manager(s)の設定を確認してみると吉。

doctrine:
    orm:
        auto_generate_proxy_classes: %kernel.debug%
        # 対象のBundleがいずれのEntityManagerにもマッピングされていない
        entity_managers:
            default:
                connection: database1
                mappings: # Required
                    AcmeAdminBundle: ~
            another:
                connection: database2
                mappings: # Required
                    AcmeUserBundle: ~

前にもハマったのと同じというオチ。。。orz