Php Symfony3可捕获的致命错误:参数1传递给Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider

Php Symfony3可捕获的致命错误:参数1传递给Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider,php,symfony,doctrine-orm,orm,doctrine,Php,Symfony,Doctrine Orm,Orm,Doctrine,我对索纳塔邦德有意见。我有错误“可捕获的致命错误:参数1传递给Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider::\uu construct()必须实现接口Symfony\Component\Security\Core\User\UserProviderInterface,FOS\UserBundle\Doctrine\UserManager的实例,在第6047行的C:\xampp\

我对索纳塔邦德有意见。我有错误“可捕获的致命错误:参数1传递给Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider::\uu construct()必须实现接口Symfony\Component\Security\Core\User\UserProviderInterface,FOS\UserBundle\Doctrine\UserManager的实例,在第6047行的C:\xampp\htdocs\PizzaProject\var\cache\dev\appDevDebugProjectContainer.php中调用并定义“

这是我的config.yml

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
    - { resource: "@PizzaBundle/Resources/config/services.yml" }
    - { resource: "@PizzaBundle/Resources/config/admin.yml" }

# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
    locale: en

framework:
    #esi: ~
    translator: { fallbacks: ['%locale%'] }
    secret: '%secret%'
    router:
        resource: '%kernel.root_dir%/config/routing.yml'
        strict_requirements: ~
    form: ~
    csrf_protection: ~
    validation: { enable_annotations: true }
    #serializer: { enable_annotations: true }
    templating:
        engines: ['twig']
    default_locale: '%locale%'
    trusted_hosts: ~
    trusted_proxies: ~
    session:
        # http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
        handler_id:  session.handler.native_file
        save_path:   "%kernel.root_dir%/../var/sessions/%kernel.environment%"
    fragments: ~
    http_method_override: true
    assets: ~
    php_errors:
        log: true

# Twig Configuration
twig:
    debug: '%kernel.debug%'
    strict_variables: '%kernel.debug%'

# Doctrine Configuration
doctrine:
    dbal:
        driver: pdo_mysql
        host: '%database_host%'
        port: '%database_port%'
        dbname: '%database_name%'
        user: '%database_user%'
        password: '%database_password%'
        charset: UTF8
        # if using pdo_sqlite as your database driver:
        #   1. add the path in parameters.yml
        #     e.g. database_path: "%kernel.root_dir%/../var/data/data.sqlite"
        #   2. Uncomment database_path in parameters.yml.dist
        #   3. Uncomment next line:
        #path: '%database_path%'

    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
    transport: '%mailer_transport%'
    host: '%mailer_host%'
    username: '%mailer_user%'
    password: '%mailer_password%'
    spool: { type: memory }

sonata_block:
    default_contexts: [cms]
    blocks:

        # enable the SonataAdminBundle block
        sonata.admin.block.admin_list:
            contexts:   [admin]

fos_user:
   db_driver: orm
   firewall_name: main
   user_class: PizzaBundle\Entity\User
   from_email:
        address: you@example.com
        sender_name: You

sonata_block:
  default_contexts: [cms]
  blocks:


  # enable the SonataAdminBundle block
  sonata.admin.block.admin_list:
  contexts: [admin]

sonata_admin:
    security:
        handler: sonata.admin.security.handler.acl

        # acl security information
        information:
            GUEST:    [VIEW, LIST]
            STAFF:    [EDIT, LIST, CREATE]
            EDITOR:   [OPERATOR, EXPORT]
            ADMIN:    [MASTER]

        # permissions not related to an object instance and also to be available when objects do not exist
        # the DELETE admin permission means the user is allowed to batch delete objects
        admin_permissions: [CREATE, LIST, DELETE, UNDELETE, EXPORT, OPERATOR, MASTER]

        # permission related to the objects
        object_permissions: [VIEW, EDIT, DELETE, UNDELETE, OPERATOR, MASTER, OWNER]
Security.yml

security:

    # http://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
    role_hierarchy:
       ROLE_SONATA_FOO_READER:
           - ROLE_SONATA_ADMIN_DEMO_FOO_LIST
           - ROLE_SONATA_ADMIN_DEMO_FOO_VIEW
       ROLE_SONATA_FOO_EDITOR: 
           - ROLE_SONATA_ADMIN_DEMO_FOO_CREATE
           - ROLE_SONATA_ADMIN_DEMO_FOO_EDIT
       ROLE_SONATA_FOO_ADMIN:
           - ROLE_SONATA_ADMIN_DEMO_FOO_DELETE
           - ROLE_SONATA_ADMIN_DEMO_FOO_EXPORT

       ROLE_STAFF:             [ROLE_USER, ROLE_SONATA_FOO_READER]
       ROLE_ADMIN:             [ROLE_STAFF, ROLE_SONATA_FOO_EDITOR, ROLE_SONATA_FOO_ADMIN]
       ROLE_SUPER_ADMIN:       [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

       ROLE_ALL_ADMIN:         [ROLE_STAFF, ROLE_SONATA_FOO_ALL]

    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

    providers:
        fos_userbundle:
           id: fos_user.user_manager

    firewalls:
        main:
           pattern: ^/
           form-login:
                provider:       fos_userbundle
                login_path:     /login
                use_forward:    false
                check_path:     /login_check
                failure_path:   null
           logout: true
           anonymous: true
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
            # activate different ways to authenticate

            # http://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
            #http_basic: ~

            # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
            #form_login: ~
    access_control:
       - { path: ^/wdt/, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/profiler/, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # AsseticBundle paths used when using the controller for assets
       - { path: ^/js/, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/css/, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # URL of FOSUserBundle which need to be available to anonymous users
       - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY } # for the case of a failed login
       - { path: ^/user/new$, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/user/check-confirmation-email$, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/user/confirm/, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/user/confirmed$, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/user/request-reset-password$, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/user/send-resetting-email$, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/user/check-resetting-email$, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/user/reset-password/, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # Secured part of the site
        # This config requires being logged for the whole site and having the admin role for the admin part.
        # Change these rules to adapt them to your needs
       - { path: ^/admin/, role: ROLE_ADMIN }
       - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }

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

    access_decision_manager:
        strategy: unanimous
    acl:
        connection: default
服务.yml

parameters:
    security.acl.permission.map:
      class: Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap
路由.yml

pizza:
    resource: "@PizzaBundle/Controller/"
    type:     annotation
    prefix:   /

admin:
  resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
  prefix: /admin

_sonata_admin:
  resource: .
  type: sonata_admin
  prefix: /admin

fos_user:
   resource: "@FOSUserBundle/Resources/config/routing/all.xml"
   prefix: /
我的实体

<?php


namespace PizzaBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;


/**
 * @ORM\Entity
 * @ORM\Table(name="fos_user")
 */
class User extends BaseUser
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    public function __construct()
    {
        parent::__construct();
        // your own logic
    }
}

您尝试使用FOSUserBundle和FOSOAuthServerBundle登录,以便使用默认的oAuth api作为默认用户提供程序,并且尝试使用grant_类型密码(在参数中发送用户凭据),将返回一条身份验证错误消息,因为您的用户名参数是用户的电子邮件/登录名。更改security.yml文件中的用户提供程序属性(如果使用FOSOAuthServerBundle,则更改config.yml)可以轻松解决此问题
更改您的服务。yml)

id:fos_user.user_manager到thes fos_user.user_provider.username

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

我在代码中发现错误。我必须更改提供程序:fos\u userbundle:id:fos\u user.user\u管理器On:providers:fos\u userbundle:id:fos\u user.user\u provider.username请添加一些解释,说明此答案如何解决问题。