1

i have a problem with doctrine and i getting this error from auto generated entity file "Class "Users" is not a valid entity or mapped super class.". File and comments inside looks like fine i dont understund why or i something miss? Some piece of code

<?php

use Doctrine\ORM\Mapping as ORM;

/**
* Users
*
* @ORM\Table(name="users", uniqueConstraints={@ORM\UniqueConstraint(name="username", columns={"username"})})
* @ORM\Entity
*/

class Users
{
   /**
  * @var integer
  *
  * @ORM\Column(name="userid", type="integer", nullable=false)
  * @ORM\Id
  * @ORM\GeneratedValue(strategy="IDENTITY")
  */

  private $userid;

/**
 * @var string
 *
 * @ORM\Column(name="username", type="string", length=100, nullable=false)
 */
  private $username;
SkySonny
  • 105
  • 2
  • 10
  • Possible duplicate of [Doctrine2 - "class" is not a valid entity or mapped super class](http://stackoverflow.com/questions/15099060/doctrine2-class-is-not-a-valid-entity-or-mapped-super-class) – Alok Patel May 13 '16 at 09:08

3 Answers3

0

Doctrine 2 annotation mapping might have been configured to negate the need for the @ORM prefix.

I would try replacing @ORM\ with @. For example @Entity

0

As far as i recall, these errors happen when doctrine cant find the entity, double check the namespace, by default the entity folder in symfony is "Entity" (Uppercase!). Also check the config files if auto_mapping is set to true.

Woffels
  • 111
  • 4
0

for me this problem was solved after adding following namespace

use Doctrine\Common\Annotations\AnnotationReader;

in my doctrine.php