本文介绍了找不到'FOS \ UserBundle \ FOSUserBundle'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在symfony 2.5中,我想使用FOSUserBundle,我在 github

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位于供应商/symfony/用户捆绑/user-bundle/FOS中这是我的AppKernel

FOSUserBundle is in vendor/friendsofsymfony/user-bundle/FOSthis is my AppKernel

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

    );

和我的app/config/config.yml

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

我的app/config/security.yml

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依靠Composers自动加载器使所有必需"的供应商都可用.如果您尚未这样做,请在composer.json文件中添加以下内容:

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"
    ...
}

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

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

php composer.phar install

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

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

这篇关于找不到'FOS \ UserBundle \ FOSUserBundle'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 20:07