简体   繁体   English

服务“ security.context_listener.0”依赖于不存在的服务“ fos_user.user_manager”

[英]The service “security.context_listener.0” has a dependency on a non-existent service “fos_user.user_manager”

I have been having this error and I don't know what is wrong with my code. 我一直遇到此错误,我不知道我的代码有什么问题。 I have checked for various ways to correct it but I can't seem to find. 我已经检查了各种方法来纠正它,但似乎找不到。

I keep getting this error: 我不断收到此错误:

The service "security.context_listener.0" has a dependency on a non-existent service "fos_user.user_manager" 服务“ security.context_listener.0”依赖于不存在的服务“ fos_user.user_manager”

This is services.yaml 这是services.yaml

parameters:
img_directory: '%kernel.root_dir%/../public/images'
imports:
    resource: parameters.yml 

locale: en

fos_user:
    db_driver: orm # other valid values are 'mongodb' and 'couchdb'
    firewall_name: main
    user_class: AppBundle\Entity\User

    from_email:
        address: "greatblog@gmail.com"
        sender_name: "Great Blog"

knp_paginator:
    page_range: 4                       # number of links showed in the pagination menu (e.g: you have 10 pages, a page_range of 3, on the 5th page you'll see links to page 4, 5, 6)
    default_options:                                 
        page_name: page                 # page query parameter name
        sort_field_name: sort           # sort field query parameter name
        sort_direction_name: direction  # sort direction query parameter name
        distinct: true                  # ensure distinct results, useful when ORM queries are using GROUP BY statements
        filter_field_name: filterField  # filter field query parameter name
        filter_value_name: filterValue  # filter value query paameter name
    template:                                        
        pagination: '@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig'     # sliding pagination controls template                                    
        sortable: '@KnpPaginator/Pagination/sortable_link.html.twig' # sort link template                                
        filtration: '@KnpPaginator/Pagination/filtration.html.twig'  # filters template

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
        public: false       # Allows optimizing the container by removing unused services; this also means
                            # fetching services directly from the container via $container->get() won't work.
                            # The best practice is to be explicit about your dependencies anyway.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
    resource: '../src/*'
    exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'

# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
    resource: '../src/Controller'
    tags: ['controller.service_arguments']

This is security.yaml 这是security.yaml

security:
providers:
    fos_user:
        id: fos_user.user_manager
encoders:
    FOS\UserBundle\Model\UserInterface: bcrypt
    # Symfony\Component\Security\Core\User\User:
    #     algorithm: bcrypt
    #     cost: 12
    # App\Entity\User:
    #     algorithm: bcrypt
    #     cost: 12

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN


firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        pattern: ^/
        form_login:
            provider: fos_user
            csrf_token_generator: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4
        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 }

Please I would need some help to know where exactly the error is coming from. 请我需要一些帮助,以了解错误的确切来源。 Thanks guys. 多谢你们。

There's an error in your security configuration. 您的安全性配置存在错误。 The provider shouldn't be user_manager . 提供者不应为user_manager

Change it to: 更改为:

security:
    providers:
        fos_user:
            id: fos_user.user_provider.username

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ServiceNotFoundException:服务“ my.facebook.user”具有对不存在的服务“ fos_user.user_manager”的依赖 - ServiceNotFoundException: The service “my.facebook.user” has a dependency on a non-existent service “fos_user.user_manager” 服务“ twig”依赖于不存在的服务“ security.context” - The service “twig” has a dependency on a non-existent service “security.context” 服务“ form.type.users”依赖于不存在的服务“ security.context” - The service “form.type.users” has a dependency on a non-existent service “security.context” Symfony 3.2“security.firewall.map.context.main”依赖于不存在的服务^我的身份验证处理程序^ - Symfony 3.2 “security.firewall.map.context.main” has a dependency on a non-existent service ^my authentication handler^ 您已请求不存在的服务“security.context” - You have requested a non-existent service “security.context” 您请求的服务“ user_service”不存在 - You have requested a non-existent service “user_service” Symfony2 FOSUserBundle-您已请求一个不存在的服务“ security.user_checker” - Symfony2 FOSUserBundle - You have requested a non-existent service “security.user_checker” 服务“sonata.block.service.container”依赖于不存在的服务“模板化” - The service “sonata.block.service.container” has a dependency on a non-existent service “templating” Symfony2错误:服务“模板”依赖于不存在的服务“ templating.globals” - Symfony2 error: The service “templating” has a dependency on a non-existent service “templating.globals” 服务“App\Decorator\DomainHydraDecorator”依赖于一个不存在的服务“api_platform.hydra.normalizer.error” - The service "App\Decorator\DomainHydraDecorator" has a dependency on a non-existent service "api_platform.hydra.normalizer.error"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM