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

heshamHanafi's avatar

what is the best to use spatie package permission role or gate laravel

I want to know the difference between gate policy and spatie package permission roles laravel what is the best for use

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

Spatie advantage is role and permissions

A role can give many permissions. You can assign the user a role, but in your code, test for permission to do something. In your code, you don't care what role they have, only that they have the right permission.

Model Policies are something else again. These determine which models the user can interact with. For example, its not sufficient to say that someone with post edit permission can edit ALL posts, they may only be allowed to edit posts that they created. The combination of permissions and policy can be important for your application.

(or it might not be - depends what you are building)

1 like

Please or to participate in this conversation.