5
votes

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

6
Do you have entity mappings set to autoload in your app/config.yml?Derek Stobbe
Why not answer Problematic's question?greg0ire
InvalidConfigurationException: Unrecognized options "auto_mapping" under "doctrine.orm" I encounter such an exception with symfony 2.1-BETAEnlightened

6 Answers

13
votes

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

/**
 * @ORM\Entity
 * @ORM\Table(name="listtype")
 */
class ListType
{
    ...
}
4
votes

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.

2
votes

I had the same problem and it turned out to be the app/config/config.yml

It needed the defintion of the default bundle as below NameBundle, then it worked fine

orm:
    auto_generate_proxy_classes: %kernel.debug%
    default_entity_manager: default
    entity_managers:
      default:
        mappings:
          NameBundle: ~
1
votes

In my case the problem was solved by changing my servers cache from eAccelerator to APC. Apparently eAccelerator strips all the comments from files which breaks your annotations.

0
votes

I had the same error, but this was because I wasn't including the Sonata Application:

try this:

add a line to your AppKernel.php

$bundles = array(
...
new Application\Sonata\UserBundle\ApplicationSonataUserBundle(),
...
0
votes

If you inherited from mapped class, you can add @ORM\SuperMappedClass in entity's annotation. You can read most information in this article.