"Class XXX is not a valid entity or mapped super class" after moving the class in the filesystem
Had this problem - don't forget the annotation * @ORM\Entity
like below:
/**
* Powma\ServiceBundle\Entity\User
*
* @ORM\Entity
* @ORM\Table(name="users")
*/
Had this problem yesterday and found this thread. I created the entity with the mapping in a new bundle (e.g. MyFooBundle/Entity/User.php), did all the configuration according to the docs but got the same error from above when trying to load the app.
In the end I realized that I wasn't loading MyFooBundle in AppKernel:
new My\FooBundle\MyFooBundle()
A great way to debug this is to run this command:
app/console doctrine:mapping:info
Do check your config.yml file, should be containing something like this:
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
types:
json: Sonata\Doctrine\Types\JsonType
orm:
auto_generate_proxy_classes: %kernel.debug%
# auto_mapping: true
entity_managers:
default:
mappings:
FOSUserBundle: ~
# ApplicationSonataUserBundle: ~
YourUserBundle: ~
SonataUserBundle: ~
Add your own bundle to the mappings list.