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

enadabuzaid's avatar

Create Dynamic Roles and Permissions

I want to use Authorization, My question is What is the best to create an Authorization

  • install package ( spatie/laravel-permission )
  • or make it manual

and advise me when using the gate and policy can create dynamic roles and permissions like a package.

0 likes
7 replies
vincent15000's avatar

I tried the spatie package, but never really used it because I prefer handling the authorizations manually.

You can do amazing authorizations just with the policies.

Gates are more used for global roles like admin, member, ... and policies for authorization like can create, can update, ... But in fact policies can do both.

1 like
bravo3's avatar

You can create groups, then create permissions inside each group (each group has its own permissions)

Then when create a new user, assign this user to that specific group, wich gonna inherit those permissions from.

Sometime, there's confusion in Django for people coming from other frameworks, they usually deal with "Roles" rather than "Groups". I'n django it's groups https://mobdro.bio/

1 like
jaseofspades88's avatar

Spatie packages are great and they'll always save you time and money. It all depends on your definition of the word 'best'.

If by 'best' you mean, it works as it says it's documented and does so very well, go for Spatie.

If by 'best' you mean, have to work out how to implement the same thing that's already been done by Spatie, testing it yourself and ensuring it works flawlessly and you have endless budget... do it yourself.

2 likes

Please or to participate in this conversation.