Search code examples
phpsymfonyfosuserbundlesymfony-2.8

Unable to generate a URL for the named route "fos_user_security_check


I have used the FOSUserBundle in the past and never have this problem. But now I am getting this error when I try to create a form action for login.

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

I followed the documentation

My 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 }

and config.yml

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

Am I missing something?

I cleared the cache and ran composer update to be sure. Also I included the bundle in the AppKernel.


Solution

  • You most likely didn't import the bundle's routing.

    See: Step 6: Import FOSUserBundle routing files