'FOSUserBundle\FOSUserBundle'未找到[英] 'FOS\UserBundle\FOSUserBundle' not found

本文是小编为大家收集整理的关于'FOSUserBundle\FOSUserBundle'未找到的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

在Symfony 2.5中,我想使用fosuserbundle,我在 github

尝试更新架构时,请参阅此错误

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

fosuserbundle在供应商/friendsofsymfony/user-bundle/fos中 这是我的appkernel

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

    );

和我的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

我的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 }

推荐答案

Symfony依靠作曲家自动加载器使所有可用的"必需"供应商.如果您还没有这样做

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

然后从项目root运行以下命令(假设您正在使用composer.phar):

php composer.phar install

这样做将更新使用的自动加载器,并应允许您在应用程序中使用fosuserbundle.

本文地址:https://www.itbaoku.cn/post/2090798.html

问题描述

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 }

推荐答案

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.