1
votes

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

3 Answers

0
votes

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
votes

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.

0
votes

for me this problem was solved after adding following namespace

use Doctrine\Common\Annotations\AnnotationReader;

in my doctrine.php