'FOS\UserBundle\FOSUserBundle' not found

為{幸葍}努か 提交于 2019-12-08 04:30:42

问题


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 }

回答1:


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.



来源:https://stackoverflow.com/questions/25236651/fos-userbundle-fosuserbundle-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!