本文介绍了symfony 中提供者和 chain_provider 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误,代码如下:

I am getting the following error, with the code below:

ServiceNotFoundException: The service "security.firewall.map.context.main" has a dependency on a non-existent service "security.user.provider.concrete.fos_user_bundle".

这是在我添加 chain_provider: 提供程序之后发生的,如果我删除它,它就可以正常工作.知道为什么吗?

This happened after I added the chain_provider: provider in it, if I remove it, it just works out fine. Any idea why?

security:
    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email
        my_fos_facebook_provider:
            id: my.facebook.user
        chain_provider:
            chain:
                providers: [fos_user_bundle, my_fos_facebook_provider]
        in_memory:
            memory:
                users:
                    user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                    admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    firewalls:
        main:
            pattern: ^/.*
            form_login:
                login_path: fos_user_security_login
                check_path: fos_user_security_check
                provider: fos_userbundle
            fos_facebook:
                app_url: "http://apps.facebook.com/myapp/"
                server_url: "http://localhost/Symfony/web/app_dev.php"
                login_path: fos_user_security_login
                check_path: fos_user_security_check
                default_target_path: /
                provider: my_fos_facebook_provider
            anonymous: true
            logout:
                path:   /logout
                target: /
                handlers: ["fos_facebook.logout_handler"]
            #http_basic:
            #    realm: "Secured Demo Area"
        login:
            pattern:  ^/login$
            security: false

推荐答案

这是 FOSFacebookBundle 文档中的一个错误.您必须使用 fos_userbundle 而不是 fos_user_bundle(注意下划线)作为提供程序名称.

It's a bug in FOSFacebookBundle docs. You must use fos_userbundle and NOT fos_user_bundle (notice the underscore) as provider name.

这篇关于symfony 中提供者和 chain_provider 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 01:28