Unable to find the controller for path "/login_check" - symfony2

authentication, php, symfony

Solution

The route `login_check` is not behind the firewall because the `login_check` route pattern matches the `login` firewall which has no security.

login:
    pattern:  ^/login     # This matches /login_check
    security: false

Solution 1: Change this to

login:
    pattern:  ^/login$
    security: false

Solution 2: Remove the `login` firewall altogether and add this rule to `access_control`

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }

Problem

I know this is a common problem. And several questions on this topic have been posted. I have tried all those solutions recommended in those questions, but none worked. I found that this problem occurs if I put my `form_login` behind a `firewall`. But I'm not having any extra layer in firewall so the path should be simple as described in documentation. My security.yml ``` # app/config/security.yml security: encoders: Joy\JoyBundle\Entity\User: algorithm: sha512 encode_as_base64: true iterations: 1 role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: administrators: entity: { class: JoyBundle:User, property: username } firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false login: pattern: ^/login security: false secured_area: pattern: ^/ anonymous: ~ form_login: login_path: login check_path: login_check logout: path: /logout target: /login access_control: - { path: ^/signup, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/, roles: ROLE_ADMIN } ``` My routing.yml in `app/config` ``` # app/config/routing.yml login: path: /login defaults: { _controller: JoyBundle:Security:login } login_check: path: /login_check joy_hello: resource: "@JoyBundle/Resources/config/routing.yml" prefix: / ``` So I'm performing login check while accessing `app_dev.php/` But it's showing that error after pressing submit in login form. Unable to find the controller for path "/login_check". Maybe you forgot to add the matching route in your routing configuration? 404 Not Found - NotFoundHttpException I tried ``` login_path: /login check_path: /login_check ``` Didn't work. What I'm missing ?? Please help.....

Original source