Symfony2 错误:找不到名为的映射文件 [英] Symfony2 Error: No mapping file found named
问题描述
我正在使用 Symfony2,当我尝试生成架构 ($ php app/console dictionary:generate:schema) 时出现错误..
<上一页>[学说ORM映射映射异常]找不到类xxxUserBundleEntityUser"的名为xxx.UserBundle.Entity.User.php"的映射文件.我的项目中只有 2 个捆绑包:
- 用户捆绑
- 文件包
我使用以下代码将 FileBundle 与 UserBundle 连接起来:
<代码>/*** @ORMManyToOne(targetEntity="xxxUserBundleEntityUser")**/受保护的$用户;代码>
文件的标题是这样的:
<代码>命名空间 xxUserBundleEntity;使用 DoctrineORMMapping 作为 ORM;/*** @ORM实体**/类用户{ ###...###}代码>
FileBundle 非常相似..谢谢!
你正在混合 Doctrine 映射格式,你在 Resources/config/doctrine 中有注解和至少一个 XML 文件
来自 symfony 文档:
"一个bundle只能接受一种元数据定义格式.例如,无法将 YAML 元数据定义与带注释的 PHP 混合实体类定义."
所以解决办法是:
您不能在给定的捆绑包中混合使用不同的 Doctrine 映射格式.所以要么对所有实体使用注解,要么对所有实体使用 XML.
I am using Symfony2 and when i try to generate the schema ($ php app/console doctrine:generate:schema) i got an error..
[DoctrineORMMappingMappingException] No mapping file found named 'xxx.UserBundle.Entity.User.php' for class 'xxxUserBundleEntityUser'.
I only have 2 Bundles in the proyect:
- UserBundle
- FileBundle
I connect the FileBundle with the UserBundle with this code:
/**
* @ORMManyToOne(targetEntity="xxxUserBundleEntityUser")
**/
protected $user;
The headers of the files are something like this:
namespace xxUserBundleEntity;
use DoctrineORMMapping as ORM;
/**
* @ORMEntity
**/
class User
{ ###...###}
FileBundle is very similar.. Thanks!
You are mixing Doctrine mapping formats, you have annotations and at least one XML file in Resources/config/doctrine
From the symfony docs:
"A bundle can accept only one metadata definition format. For example,
it's not possible to mix YAML metadata definitions with annotated PHP
entity class definitions."
So the solution is:
You cannot mix different Doctrine mapping formats in a given bundle. So either use annotations for all entities or use XML for all.
这篇关于Symfony2 错误:找不到名为的映射文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!