Symfony 2.3 FOSUserBundle找不到security.context [英] Symfony 2.3 FOSUserBundle does not find security.context

查看:74
本文介绍了Symfony 2.3 FOSUserBundle找不到security.context的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我像下面提到的那样安装了FOS Bundle: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master /Resources/doc/index.md

I installed the FOS Bundle like mentioned in: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md

使用composer安装并设置用户类后,我总是得到:

After installation with composer and setting up the user class i always get:

[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
 The service "fos_user.security.login_manager" has a dependency on a non-exi
 stent service "security.context".

我检查了路径的存在,并且fosuserbundle中包含了contextinterface ... 使用控制台始终会中止,并出现相同的错误. 有人吗?

I checked the existence of the path and there is the contextinterface that is included in the fosuserbundle... Using the console always aborts with the same error. Anyone?

我在appKernel中启用了该捆绑包(在其中也激活了安全捆绑包):

I enabled the bundle in appKernel (where the security bundle also is activated):

        ...
        new Symfony\Bundle\SecurityBundle\SecurityBundle(),
        ...
        new FOS\UserBundle\FOSUserBundle(),
        ...

我将配置添加到config.yml:

I added the config to the config.yml:

# fos UserBundle config
fos_user:
    db_driver: orm
    firewall_name: main
    user_class: SDDB\MainBundle\Entity\User

我扩展了routing.yml:

I extended the routing.yml:

# USER AUTH STUFF

fos_user_security:
    resource: "@FOSUserBundle/Resources/config/routing/security.xml"

fos_user_profile:
    resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
    prefix: /profile

fos_user_register:
    resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
    prefix: /register

fos_user_resetting:
    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
    prefix: /resetting

fos_user_change_password:
    resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
    prefix: /profile

和security.yml:

and the 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 }

推荐答案

添加:
-{resource:security.yml}到主config.yml中的import部分,它为我解决了这个问题

Add :
- { resource: security.yml } to the import section in the main config.yml, it solved the problem for me

这篇关于Symfony 2.3 FOSUserBundle找不到security.context的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆