AnchovyLegend
AnchovyLegend

Reputation: 12538

Doctrine class is not a valid entity or mapped super class

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!

Upvotes: 0

Views: 7121

Answers (1)

Igor Pantović
Igor Pantović

Reputation: 9246

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\....
     */
    

Upvotes: 1

Related Questions