【问题标题】:Symfony 2 - Class "Mingle\StandardBundle\Entity\Product" is not a valid entity or mapped superclassSymfony 2 - 类“Mingle\StandardBundle\Entity\Product”不是有效的实体或映射的超类
【发布时间】:2015-06-23 05:32:02
【问题描述】:

我在我的包Mingle\StandardBundle\Entity 中创建了一个Product.php 文件,如下所示:

<?php

namespace Mingle\StandardBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/*
 * @ORM\Entity
 * @ORM\Table(name="product")
 */

class Product
{
    /*
     * @ORM\Column(type="integer")
     * @ORM\ID
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
    /*
     * @ORM\Column(type="string",length=100)
     */
    protected $name;
    /*
     * @ORM\Column(type="decimal",scale=2)
     */
    protected $price;
    /*
     * @ORM\Column(type="text")
     */
    protected $description;
}
?>

在 Ubuntu 终端中,在 Symfony 项目的根文件夹中,我输入了以下命令:

php app/console doctrine:generate:entities Mingle/StandardBundle/Entity/Product

我遇到了问题:

[Doctrine\ORM\Mapping\MappingException]                                      
  Class "Mingle\StandardBundle\Entity\Product" is not a valid entity or mapped super class.

而且我搜索后也不知道如何解决。请帮忙

【问题讨论】:

    标签: php symfony doctrine entity bundle


    【解决方案1】:

    注释必须放在/** */注释块内,否则无法识别。

    【讨论】:

    • 你正在使用/* */评论块,开头应该有两个星号
    • 谢谢,我摆脱了那个错误,但是遇到了一些不同的问题,我会寻找更多的解决方案
    猜你喜欢
    • 1970-01-01
    • 2018-01-15
    • 2011-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-12
    • 1970-01-01
    • 2014-02-21
    相关资源
    最近更新 更多