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

dmhall0's avatar

Laratrust vs Spatie Permission Experience?

I need to implement a user roles and permissions package. Needs to have a team function as well. Anyone have experience with either Laratrust or Spatie Permissions? Pros or Cons of each? Or any suggestion of a different package?

0 likes
11 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Both Laratrust and Spatie Permissions are great packages for implementing user roles and permissions. Here are some pros and cons of each:

Laratrust:

  • Pros:
    • Easy to use and understand.
    • Provides a lot of features out of the box.
    • Good documentation.
  • Cons:
    • Can be slow for large applications.
    • Limited customization options.

Spatie Permissions:

  • Pros:
    • Lightweight and fast.
    • Highly customizable.
    • Good documentation.
  • Cons:
    • Requires more setup and configuration than Laratrust.
    • Some features may require additional packages.

Ultimately, the choice between the two will depend on your specific needs and preferences. If you need a lot of features and don't mind sacrificing some speed, Laratrust may be the better option. If you need something lightweight and highly customizable, Spatie Permissions may be the way to go.

As for a different package, another popular option is Bouncer. It's similar to Laratrust and Spatie Permissions in terms of functionality, but has a slightly different approach to implementation.

Here's an example of how to use Spatie Permissions to create roles and permissions:

// Create a role
$role = Role::create(['name' => 'admin']);

// Create a permission
$permission = Permission::create(['name' => 'edit articles']);

// Assign the permission to the role
$role->givePermissionTo($permission);

// Assign the role to a user
$user->assignRole('admin');

// Check if a user has a permission
$user->hasPermissionTo('edit articles');
2 likes
dmhall0's avatar

Lary,

Thank you for the reply and overall pretty good answer.

Just curious if there are any real humans out there that may have some thoughts?

cwhite's avatar

@dmhall0,

Just curious if there are any real humans out there that may have some thoughts?

Wow such AIist lol.

We're in the same boat and are considering Bouncer, but haven't got around to revamping our current permissions yet.

dmhall0's avatar

@cwhite

I thought about Bouncer but I need permissions / roles to also allow for different teams; and I don't see it in the docs.

cwhite's avatar

@dmhall0 ah interesting, it looks like Laratrust is the only package that supports that out of the three mentioned above

1 like
sKaspy's avatar

@dmhall0 Thank you for this hint!!! Would propably not found out about it since all blog posts comparing Spatie and Laratrust are outdated and mention that only Laratrust offers the team feature.

Nesster's avatar

We are also looking into implementing a role/permission system with teams. I've played with spatie/laravel-permission with the teams feature and works OOTB with Laravel gates, don't know about the other packages.

The current challenge for us is to implement spatie team roles over Jetstream's. We like the Jetstream's team implementation, but need more granular permissions, hence the spatie package. We are at a point where we have something working but need to address the duplication of roles we're stuck with: one in jetstream's "team_user" model/table and one in spatie "roles" model/table.

If someone has had experience going this route we'd be very interested in hearing about possible ways of going about this. Cheers!

dmhall0's avatar

@Nesster The more I have used these packages the more I question if they are really needed for my application. I suggest you ask yourself several questions...

  1. Can a user be part of multiple teams and have a different role for each team? If answer is no, then the team feature of these packages is pointless.
  2. Can a user have multiple roles within the same team? Again, if not, then much of the features and complexity of these packages goes away.
  3. Can a user have permission assigned directly to themself or are permissions only through the role? Again, it not, then simplicity wins here.

I implemented Laratrust and it is working. But, I don't think I need it. I find it to be too much for my application. Users are part of only one team, they can have only one role, and they cannot have their own permissions. Also, every check of permission in a blade file, Laratrust runs another set of queries (i.e. get user's role and then check if that role has the needed permission). This is leading to A LOT of extra queries in some of my blade files. I plan to eventually remove the package and just manage it through policies, but we will see.

Let me know if any of this was helpful. Good luck with your project!

3 likes
Nesster's avatar

@dmhall0 Very well summed up, those questions are pretty much the ones we explored and alas, we pretty much need them all. It was actually a mission of mine to keep it as simple as possible in regard to authorization but requirements are more complicated than that.

I had read about a possible performance hit with Laratrust, thank you for sharing your hands on experience. It confirms our choice of spatie/laravel-permission in this matter.

Your reply was very useful indeed. I'd also like to give back eventually on how we end up managing it all, the simplest way possible ;-)

2 likes
ramWeb's avatar

i think lara trust is best package

Please or to participate in this conversation.