Doctrine类不是有效的实体或映射的超类 [英] Doctrine class is not a valid entity or mapped super class

查看:214
本文介绍了Doctrine类不是有效的实体或映射的超类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当运行以下命令时:



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;
}

我一直在尝试调试一段时间,我感谢任何关于如何解决这个问题的建议。



非常感谢提前!

解决方案

我可以看到两个错误:


  1. 没有getter和setters


  2. 您的注释格式无效。



    应该是

      / ** 
    * @ 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:

  1. No getters and setters

  2. Your annotations are in invalid format. You are missing one * at opening everywhere.

    It should be

    /**
     * @ORM\WhateverHere
     */
    

    And you have

    /*
     * @ORM\....
     */
    

这篇关于Doctrine类不是有效的实体或映射的超类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆