1

I just started learning Symfony2 and I'm following the examples from "The Cookbook" from Symfony's website.

When trying the code from the chapter about loading users from database (Entity Provider) (Link to the chapter) I get the following error:

MappingException: Class Acme\UserBundle\Entity\User is not a valid entity or mapped super class.

... and can't find out wthat I am doing wrong. I do think I followed all the steps provided in the chapter.

Thanks for any help,

2 Answers 2

1

I finally found the problem when revising step by step the whole code.

I forgot to register UserBundle in AppKernel.php.

Sign up to request clarification or add additional context in comments.

Comments

0

I have the same problem. I looked at symfony+Mapping error but that solution not works for me. Then I found, that Michi solution works https://stackoverflow.com/a/10935672/2910183

So, here is what I do at all:

  1. register bundle in AppKernel.php:

    new Acme\UserBundle\AcmeUserBundle(),

  2. create this bundle (it is just a copy of FOS\UserBundle\FOSUserBundle) and save as src/Acme/UserBundle/AcmeUserBundle.php

    <?php
    namespace Acme\UserBundle;
    use Symfony\Component\HttpKernel\Bundle\Bundle;
    use Symfony\Component\DependencyInjection\ContainerBuilder;
    use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
    use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass;
    use Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\DoctrineCouchDBMappingsPass;
    class AcmeUserBundle extends Bundle {
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.