0

I'm developping a website on Symfony2, I want to intergrate FOSUserBundle. I am using Doctrine ORM User class. I've followed the installation steps but I got this error:

ClassNotFoundException in AppKernel.php line 21:
Attempted to load class "FOSUserBundle" from namespace "FOS\UserBundle".
Did you forget a "use" statement for another namespace?

AppKernel.php:

    public function registerBundles()
{
    $bundles = array(
        ...
        new FOS\UserBundle\FOSUserBundle(),
    );

It looks correctly placed: FOSUserBundle.php is located in \vendor\friendsofsymfony\userbundle

And the namespace is correct I think: namespace FOS\UserBundle;

Other files:

#config.yml

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: REMERA\PlatformBundle\Entity\User

#routing.yml

fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

#security.yml

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4
            logout:       true
            anonymous:    true

    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }

I've been trying to solve this for hours, answers on other similar questions don't resolve my error. Am I missing something? Thanks in advance.

5
  • Maybe you have dumped an autoloader earlier ? Try php composer.phar dump-autoload --optimize Commented Jun 16, 2015 at 9:29
  • It doens't seem to be this, the error is persisting Commented Jun 16, 2015 at 9:36
  • try to clear the cache first. Then if it is still not working, composer remove, composer require and composer update again. Commented Jun 16, 2015 at 9:49
  • Thank you, that solved ClassNotFoundException. I now have another error that I'll try to solve on my own first haha... Would you mind explaining what was my problem? I don't fully understand Commented Jun 16, 2015 at 10:03
  • Clearing the cache often solves issues that you don't understand... Caching is really a complicated thing, so well... I don't know neither ^^ Commented Jun 16, 2015 at 10:10

2 Answers 2

1

How this was solved:

try to clear the cache first. Then if it is still not working, composer remove, composer require and composer update again. – Brewal

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

Comments

0

When you try to clear cache but its not getting cleared you should use --no-warmup option, this will make sure that you cache is re-generated and cache is not warmed up only. I think this can help you:

php app/console cache:clear --env=prod --no-warmup

or

php app/console cache:clear --env=dev --no-warmup

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.