【问题标题】:Unable to generate a URL for the named route "fos_user_security_check无法为命名路由“fos_user_security_check”生成 URL
【发布时间】:2016-11-03 20:24:53
【问题描述】:

我过去使用过 FOSUserBundle,从来没有遇到过这个问题。但是现在当我尝试为登录创建表单操作时出现此错误。

<form action="{{ path('fos_user_security_check') }}" method="post">

我关注了documentation

我的 security.yml:

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

    role_hierarchy:
            ROLE_ADMIN:       ROLE_USER
            ROLE_SUPER_ADMIN: ROLE_ADMIN


    providers:
            fos_userbundle:
                id: fos_user.user_provider.username

    providers:
        in_memory:
            memory: ~

    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        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

    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 }

和 config.yml

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

我错过了什么吗?

我清除了缓存并运行了 composer update 来确定。 我还将捆绑包包含在 AppKernel 中。

【问题讨论】:

  • 您安装了捆绑包吗?执行app/console debug:router 检查路径

标签: php symfony fosuserbundle symfony-2.8


【解决方案1】:

您很可能没有导入捆绑包的路由。

见:Step 6: Import FOSUserBundle routing files

【讨论】:

  • 谢谢。下次我应该更加小心。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-12-15
  • 2014-02-06
  • 2021-06-08
  • 2014-12-06
  • 1970-01-01
  • 2013-06-25
  • 2013-07-07
相关资源
最近更新 更多