0

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!

1ed
  • 3,668
  • 15
  • 25
AnchovyLegend
  • 12,139
  • 38
  • 147
  • 231

1 Answers1

1

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\....
     */
    
Igor Pantović
  • 9,107
  • 2
  • 30
  • 43
  • 3
    1. An entity doesn't need getters and setters to be valid. 2. Yes, this is actually correct. You probably need to add another asterisk in the first comment line, in all comments. – Pedro Cordeiro Oct 02 '13 at 20:42
  • You're absolutely right, it can still get mapped. But he will need them if he wants to manipulate `protected` properties (in any sane way) :) – Igor Pantović Oct 02 '13 at 20:45