Symfony2错误使用doctrine:generate:实体创建Getters和Setters [英] Symfony2 Error Using doctrine:generate:entities to Create Getters and Setters

查看:172
本文介绍了Symfony2错误使用doctrine:generate:实体创建Getters和Setters的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的第一个包中创建了几个实体,没有任何问题。但是当我创建一个新的包时,使用正常的命令:

  php app / console generate:bundle 

这将创建一个包含模板文件的软件包结构,并将该软件包注册到app / config / AppKernel.php中



然后我在新的包文件夹中创建了实体: / Acme / Bundle / Entity /



但是当我使用命令生成getter和setter:

  php app / console doctrine:generate :实体AcmeBundle 

它发出错误:

  [RuntimeException] 
包AcmeBundle不包含任何映射的实体。

为什么没有找到这些实体?

解决方案

这是由于新的捆绑包未自动注册在/app/config/config.yml文件中。所以教义不知道在哪里明确寻找实体。



如果只有一个ORM数据库连接,这可能不是问题。但是,如果您使用特殊的ORM映射定义了多个连接,则需要记住使用正确的实体管理器连接注册每个单个捆绑:

  doctrine:
orm:
default_entity_manager:cms
entity_managers:
cms:
connection:cms
mappings:
GutensiteCmsBundle:〜
GutensiteArticleBundle:〜
结算:
连接:计费
映射:
GutensiteBillingBundle:〜

似乎应该有一个更好的方法来让所有实体使用默认的默认,所以你不必每次都这样做。有人知道吗?


I've created several entities in my first bundle without any problems. But when I create a new bundle, using the normal command:

php app/console generate:bundle

This creates a bundle structure with template files and registers the bundle in the app/config/AppKernel.php

I then created entities inside the new bundle folder: /Acme/Bundle/Entity/.

But when I go to generate the getters and setters with the command:

php app/console doctrine:generate:entities AcmeBundle

It gives an error:

[RuntimeException]                                                     
Bundle "AcmeBundle" does not contain any mapped entities. 

Why are these entities not being found?

解决方案

This was caused by the fact that the new bundle is not automatically registered in the /app/config/config.yml file. So doctrine didn't know where to look for the entities evidently.

Maybe this isn't a problem if you only have one ORM database connection. But if you have defined multiple connections with special ORM mapping, you need to remember to register Every Single Bundle with the right entity manager connection:

doctrine:
    orm:
        default_entity_manager: cms
        entity_managers:
            cms:
                connection: cms
                mappings:
                    GutensiteCmsBundle: ~
                    GutensiteArticleBundle: ~
            billing:
                connection: billing
                mappings:
                    GutensiteBillingBundle: ~

It seems like there should be a better way to have all entities use the default one by... "default" so you don't have to do this every time. Anyone know?

这篇关于Symfony2错误使用doctrine:generate:实体创建Getters和Setters的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆