无法为命名路由“fos_user_security_check 生成 URL

Unable to generate a URL for the named route "fos_user_security_check

我以前使用过 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

我错过了什么吗?

我清除了缓存并 运行 作曲家更新以确保。 我还把这个包包含在 AppKernel 中。

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

参见:Step 6: Import FOSUserBundle routing files