簡體   English   中英

Symfony2.8上的Symfony \\ Component \\ Config \\ Definition \\ Exception \\ InvalidTypeException

[英]Symfony\Component\Config\Definition\Exception\InvalidTypeException on Symfony2.8

我正在嘗試在Synfony 2.8上使用FosUserBundle設置登錄名,但是在嘗試啟動服務器時出現此錯誤

[Symfony \\ Component \\ Config \\ Definition \\ Exception \\ InvalidTypeException]
路徑“ security.firewalls.pattern”的類型無效。 預期的數組,但有字符串

這是security.yml文件

# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:
    providers:
        in_memory:
            memory: ~
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager
        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

        main:
            anonymous: ~
            # activate different ways to authenticate

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

            # form_login: ~
            # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
        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 }
    encoders:
        UserBundle\Entity\User:
            algorithm: bcrypt
            cost: 12
        FOS\UserBundle\Model\UserInterface: bcrypt

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

這是config.yml文件

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

parameters:
    locale: en

framework:
    translator:      { fallbacks: [en] }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    templating:
        engines: ['twig']
    default_locale:  es
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
        handler_id:  ~
    fragments:       ~
    http_method_override: 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

    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 }

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

我想我已經遵循了官方文件,但是沒有用

看來您必須重構防火牆:

 firewalls:
     dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false

     main: 
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager
        logout:       true
        anonymous:    true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM