Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mona_Salih12's avatar

Authentication Guard

I have the following role ("Admin", "JobCoach", "Company ", "Manager ") , How I can add them to guards in config\auth.php

0 likes
10 replies
Snapey's avatar

Dont.

Use a single guard and use roles to determine what people can do.

Use guards for different authentication methods not for different classes of user

1 like
Snapey's avatar

@Mona_Salih12 You can add columns to the user table with boolean flags for each role (allows one user to have many roles) or you can have a single field that contains a string identifying their role (user can only ever have one role) or you can implement a roles package such as Spatie Permissions

2 likes
Mona_Salih12's avatar

@Snapey

Thank you very much for your assistance. Could you please provide me with a link or some guidance on how to use guards? I appreciate your help in advance.

jlrdw's avatar

@Mona_Salih12 Just FYI, this forum being 9+ years old already has discussions on:

  • usage of authorization instead of multi guards to determine who can and cannot do something

  • also usage of multiple guards

  • in depth discussions of authentication and authorization in general (some very detailed).

But again just some fyi.

Please or to participate in this conversation.