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

JudyBlosser's avatar

What is the difference between gates and policies?

i didn't quite understand the difference between gates and policies from the documentation, and i couldn't find any screencast about them.

can anyone please explain the difference, and how can i use it to check for users roles like admin, superadmin, i know about packages like entrust, but i'am looking for pure laravel way of doing it.

0 likes
4 replies
jlrdw's avatar

Kinda like their names, a gate keeps someone out but a policy is kinda like the instructions telling gate who is allowed and not allowed.

8 likes
siangboon's avatar

Both also for authorizing user actions against a given resource. Gates is more general use to provide a simple, closure based approach to overall authorization. Policies is more group their logic around a particular model or resource.

I would think like gate is usually apply to company and each departments have their own set policies.

1 like

Please or to participate in this conversation.