Doctrine类不是有效的实体或映射的超类 [英] Doctrine class is not a valid entity or mapped super class
问题描述
当运行以下命令时:
php app / console doctrine:generate:entities Foo / FooBundle / Entity / Company
我收到以下错误:
`[Doctrine\ORM\Mapping\MappingException]
类Foo\FooBundle\Entity\Company不是有效的实体或映射的超类。
实体/ Company.php
命名空间Foo\FooBundle\Entity;
使用Doctrine\Common\Annotations\AnnotationReader;
使用Doctrine\ORM\Mapping作为ORM;
/ **
* @ ORM\Entity
* @ ORM\Table(name =product)
* /
class公司
{
/ *
* @ ORM\Id
* @ ORM\Column(type =integer)
* @ ORM\GeneratedValue(strategy =AUTO)
* /
protected $ id;
/ *
* @ ORM\Column(type =string,length = 250)
* /
protected $ name;
/ *
* @ ORM\Column(type =string,length = 650)
* /
protected $ description;
}
我一直在尝试调试一段时间,我感谢任何关于如何解决这个问题的建议。
非常感谢提前!
我可以看到两个错误:
-
没有getter和setters
-
您的注释格式无效。
应该是
/ **
* @ ORM\WhateverHere
* /
你有
/ *
* @ ORM\ ....
* /
I am new to Doctrine and Symfony and I am having a really difficult time creating an entity.
When running the following command:
php app/console doctrine:generate:entities Foo/FooBundle/Entity/Company
I am getting the following error:
`[Doctrine\ORM\Mapping\MappingException]
Class "Foo\FooBundle\Entity\Company" is not a valid entity or mapped super class.`
Entity/Company.php
namespace Foo\FooBundle\Entity;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\ORM\Mapping as ORM;
/**
*@ORM\Entity
*@ORM\Table(name="product")
*/
class Company
{
/*
*@ORM\Id
*@ORM\Column(type="integer")
*@ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/*
*@ORM\Column(type="string", length=250)
*/
protected $name;
/*
*@ORM\Column(type="string", length=650)
*/
protected $description;
}
I have been trying to debug this for quite some time now, I appreciate any advice on how to troubleshoot this problem.
Many thanks in advance!
Two mistakes I can see:
No getters and setters
Your annotations are in invalid format. You are missing one * at opening everywhere.
It should be
/** * @ORM\WhateverHere */
And you have
/* * @ORM\.... */
这篇关于Doctrine类不是有效的实体或映射的超类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!