Home » Php » php – Symfony3 No route found for "GET /logout"

php – Symfony3 No route found for "GET /logout"

Posted by: admin July 12, 2020 Leave a comment

Questions:

I cant seam to get the logout working on symfony3. I’ve been following the symfony documentation SecurityBundle Configuration and as far as I can tell my config file seams to be by there specification yet when i go to /logout i get the following response:

No route found for "GET /logout" (from "http://localhost:8000/admin").

Any ideas on what my problem could be?

My security.yml:

security:
encoders:
    AppBundle\Entity\User:
        algorithm: bcrypt
    Symfony\Component\Security\Core\User\User: plaintext
providers:
    chain_provider:
            chain:
                providers: [in_memory, database_provider]
    in_memory:
        memory:
          users:
            test:
                password: test
                roles: 'ROLE_ADMIN'
            admin:
                password: admin
                roles: 'ROLE_ADMIN'
    database_provider:
        entity:
            class: AppBundle:User
            property: email
firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        anonymous: true
        logout: true
        form_login:
            check_path: /login
            login_path: /login
            default_target_path: /login
            always_use_default_target_path: true
        logout:
            path:   /logout
            target: /login
How to&Answers:

The awsver is so simple I almost removed the question, but I guess having a well configured security.yml can be a good example for other who are having problems.

just add the route to route.yml

# app/config/routing.yml
logout:
   path: /logout