Symfony2:无法识别的选项" admin"在" security.providers.in_memory.memory"

时间:2015-08-31 18:55:28

标签: php symfony twig symfony-forms symfony-2.7

我尝试

时出现此问题
  

php app / console server:运行

它告诉我这个错误:

无法识别的选项" admin"在" security.providers.in_memory.memory"

这是我的 security.yml

security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext
        Custom\CMSBundle\Entity\User: bcrypt
    role_hierarchy:
        ROLE_ADMIN: [ROLE_USER]
    providers:
        chain_providers:
            chain:
                providers: [in_memory, user_db]
        in_memory:
            memory:
                users:
                admin: { password: adminpass, roles: ROLE_ADMIN }
        user_db:
            entity: { class: CustomCMSBundle:User, property: username }
    firewalls:
        main:
            pattern: /.*
            form_login:
                login_path: /login
                check_path: /login_check
                default_target_path: /
            logout:
                path: /logout
                target: /
            security: true
            anonymous: true
    access_control:
            - { path: /login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: /cms/user, roles: ROLE_ADMIN }
            - { path: /.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }

1 个答案:

答案 0 :(得分:1)

定义的用户(在这种情况下为admin)应该在users地图内定义,因此必须缩进超过users

in_memory:
    memory:
        users:
            admin: { password: adminpass, roles: ROLE_ADMIN }