Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class ..Entity\User is not a valid entity or mapped super class

Tags:

symfony

I'm getting this error when I try to clear the cache (for example):

[Doctrine\ORM\Mapping \MappingException] Class Aib\PlatformBundle\Entity\User is not a valid entity or mapped super class.

This is User.php:

<?php
// src/Aib/PlatformBundle/Entity/User.php

namespace Aib\PlatformBundle\Entity;

use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="fos_user")
 */
class User extends BaseUser
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    public function __construct()
    {
        parent::__construct();
        // your own logic
    }

}

And this is the place where User.php is stored:

javier@javier:~/programacion/aib/src/Aib/PlatformBundle/Entity$ ls User.php UserRepository.php

This is the AppKernel.php:

public function registerBundles()
{
    $bundles = array(
        ...
        new Aib\PlatformBundle\AibPlatformBundle(),
        ...
    );

sf 2.0.4

like image 223
ziiweb Avatar asked Nov 03 '11 13:11

ziiweb


2 Answers

In my case I was missing * @ORM\Entity in my class definition.

/**
 * @ORM\Entity
 * @ORM\Table(name="listtype")
 */
class ListType
{
    ...
}
like image 143
Reza S Avatar answered Sep 30 '22 08:09

Reza S


I had the exact same experience with my implementation of the FOS UserBundle and found I was able to resolve the issue by removing the MyBundle\Resources\config\doctrine folder.

I dont fully understand the cause (newbie) but think the issue is a result of having database content built in bother directions, ie from doctrine entities and by reverse engineering some tables.

like image 42
MadManMonty Avatar answered Sep 30 '22 07:09

MadManMonty