Search code examples
phpfosuserbundlesymfony-2.5

'FOS\UserBundle\FOSUserBundle' not found


in symfony 2.5 I want use FOSUserBundle, I do any steps in github

and when try to update schema see this error

Fatal error: Class 'FOS\UserBundle\FOSUserBundle' not found in /opt/lampp/htdocs/symfonyTest/app/AppKernel.php on line 23

FOSUserBundle is in vendor/friendsofsymfony/user-bundle/FOS this is my AppKernel

$bundles = array(
        //... other bundles
        new FOS\UserBundle\FOSUserBundle(),

    );

and my app/config/config.yml

fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Acme\StoreBundle\Entity\User

my app/config/security.yml

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

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: form.csrf_provider
        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 }

Solution

  • Symfony relies on Composers autoloader to make all of the "required" vendors available. IF you havent done so already add the following to your composer.json file:

    "require": {
        "friendsofsymfony/user-bundle": "~2.0@dev"
        ...
    }
    

    Then run the following command from your project root(assuming you are using the composer.phar):

    php composer.phar install
    

    Doing this will update the autoloader used and should allow you to use the the FOSUserBundle in your application.