I am managing users in my symfony2 project. I am able to login and logout without problems. Now, I would like to create a logout link (instead of typing app_dev.php/logout).
I have tryed
<a href="/logout">Logout</a>
But this link is deleting the app_dev.php and i have only /logout which does not exist.
here is my security.yml
security:
encoders:
MDPI\BackendBundle\Entity\Users:
id: mdpi.backend.backendencoder.class
providers:
secured_area:
entity: { class: MDPI\BackendBundle\Entity\Users, property: email }
firewalls:
secured_area:
pattern: ^/
anonymous: ~
form_login:
login_path: /login
check_path: /login_check
logout:
path: /logout
target: /
access_control:
- { path: ^/(?!login)(.*), role: ROLE_admins }
- { path: /login.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
Thank you very much.
I created the link this way: (I use TWIG)
And in my “UserBundle”, in the routing.yml file added