名称空间不';t在Symfony 2中不包含映射实体
我在src/Andrei/StatisticsBundle/entity/Attribute/Value/ButtonVarchar.php中创建了一个新实体。以下是该类的代码:名称空间不';t在Symfony 2中不包含映射实体,symfony,doctrine,Symfony,Doctrine,我在src/Andrei/StatisticsBundle/entity/Attribute/Value/ButtonVarchar.php中创建了一个新实体。以下是该类的代码: <?php namespace Andrei\StatisticsBundle\Entity\Attribute\Value; class ButtonVarchar { protected $value; } 出于某种原因,当我运行php应用程序/控制台原则:generate:entities时,
<?php
namespace Andrei\StatisticsBundle\Entity\Attribute\Value;
class ButtonVarchar
{
protected $value;
}
出于某种原因,当我运行php应用程序/控制台原则:generate:entities时,我得到以下错误:
[RuntimeException] Namespace "Andrei\StatisticsBundle\Entity\Attribute\Value" does not contain any mapped entities.
我不明白为什么会这样。有人能给我指一下正确的方向吗?谢谢。您的实体似乎被分成了细粒度的包。在这种情况下,您需要指定
完全限定的命名空间
,以便它工作
targetEntity: Fully\Qualified\Namespace\To\Button
您是否已将统计数据包添加到配置中 例如: 您可以在以下链接中看到映射问题: 这也可能有帮助 这项工作:
MyUniqBundle:Entity
这不起作用:
MyUniqBundle/Entity
配置文件的名称不应该是
ButtonVarchar.orm.yml
?这就是问题所在。非常感谢。但由于某些原因,在重命名后,我在运行cli命令时出现以下错误:映射文件无效类“Andrei\StatisticsBundle\Entity\ButtonVarchar”的映射文件“Andrei.StatisticsBundle.Entity.ButtonVarchar.orm.yml”无效。请检查此文件:我找到了。我的db映射文件名应命名为Attribute.Value.ButtonVarchar.orm.yml,而不是ButtonVarchar.orm.yml,但它适用于位于Andrei/StatisticsBundle/Entity中的所有实体。如果我使用Andrei\StatisticsBundle\Entity\Attribute\Value中的实体,则会出现问题。我认为,您不使用\Attribute\Value目录中的实体,而是将其放入Andrei\StatisticsBundle\Entity中。条令可能只从实体根解析。
MyUniqBundle:Entity
MyUniqBundle/Entity