本文介绍了命名空间不包含Symfony 2中的映射实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在src / Andrei / StatisticsBundle / Entity / Attribute / Value / ButtonVarchar.php中创建了一个新实体。这是这个类的代码:

I've created a new entity in src/Andrei/StatisticsBundle/Entity/Attribute/Value/ButtonVarchar.php. Here is the code for this class:

<?php

namespace Andrei\StatisticsBundle\Entity\Attribute\Value;

class ButtonVarchar
{
    protected $value;
}

和src / Andrei / StatisticsBundle / Resources / config / doctrine / ButtonVarchar。 yml我定义了以下映射信息:

and in src/Andrei/StatisticsBundle/Resources/config/doctrine/ButtonVarchar.yml I defined the following mapping information:

Andrei\StatisticsBundle\Entity\Attribute\Value\ButtonVarchar:
    type: entity
    table: button_attribute_value_varchar
    id:
        id:
            type: integer
            generator: { strategy: AUTO }
    fields:
        value:
            type: string
            length: 255
    manyToOne:
        button:
            targetEntity: Button
            inversedBy: attributeValues
            joinColumn:
                name: button_id
                referencedColumnName: id

由于某些原因,当我运行php app / console doctrine:generate:entities我得到以下错误:

For some reason when I run php app/console doctrine:generate:entities I get the following error:

[RuntimeException] Namespace "Andrei\StatisticsBundle\Entity\Attribute\Value" does not contain any mapped entities.

我不明白为什么会发生这种情况。有人可以指向正确的方向吗?谢谢。

I can't understand why is this happening. Can someone point me to the right direction? Thank you.

推荐答案

您是否将StatisticsBundle添加到了Doctrine配置?

Did you add your StatisticsBundle to Doctrine config?

eg:

doctrine:
  orm:
    auto_mapping: true
    mappings:
         AndreiStatisticsBundle: ~

可以在以下链接中看到映射问题:

You can see mapping problem in the following link:

这篇关于命名空间不包含Symfony 2中的映射实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 01:15