Reputation: 1508
I have 2 bundles, 1 CMS bundle that will be the parent bundle.
I have in both bundles duplicated entitys. Like User
The user in the CMS bundle i made it a abstract class. (not sure if that is the right choice. Actually, what I want is extending my user entity IF needed.).
cms user:
abstract class User implements UserInterface
bundle user:
use MV\CMSBundle\Entity\User as BaseUser;
/**
* @ORM\Entity(repositoryClass="MV\NameBundle\Repository\UserRepository")
* @DoctrineAssert\UniqueEntity(fields={"email"}, message="user.email.already.exist" )
*/
class User extends BaseUser
{
....
}
Im getting the error Class "MV\CMSBundle\Entity\User" is not a valid entity or mapped super class.
I have searched in the documentation of symfony and found this page: entities-entity-mapping but they didn't add some content xD
Oh, and no I dont want to use FOSUserBundle ;)
Symfony: 2.1
Upvotes: 17
Views: 40447
Reputation: 14747
I had the same problem in linux server. Be careful with case sensitive. I had to replace this:
/**
* @entity
* @table(name="listtype")
*/
class ListType
{
...
}
With this:
/**
* @Entity
* @Table(name="listtype")
*/
class ListType
{
...
}
Upvotes: 0
Reputation: 21817
Define the base-class as follows:
/**
* @ORM\MappedSuperclass
*/
abstract class BaseUser
{
// ...
}
Define the real entity:
/**
* @ORM\Entity
*/
class User extends BaseUser
{
// ...
}
Because you're missing the @MappedSuperclass annotation on the base-class, Doctrine throws the exception you mention.
Upvotes: 27
Reputation: 51
I had the same problem. But to make it work but, I had to shift the lines:
* @ORM\Table
* @ORM\Entity
Upvotes: 5
Reputation: 9738
In my case I was missing * @ORM\Entity
in my class definition.
/**
* @ORM\Entity
* @ORM\Table(name="listtype")
*/
class ListType
{
...
}
Upvotes: 30
Reputation: 7309
In my case, the problem was eaccelerator
because it strips out all the comments which Doctrine uses. After disabling eaccelerator
it worked . You can disable your php settings or,
in the web/app_dev.php
or web/app.php
file.
<?php
ini_set('eaccelerator.enable', 0);
ini_set('eaccelerator.optimizer', 0);
//rest of the code.
Note: Do clear the symfony2 cache after disabling this.
Upvotes: 5