Associate users with roles and permissions
$ npx -y skills add spatie/laravel-permission --agent claude-code
Run the curl in your terminal, the rest in Claude Code.
What's inside

See the documentation for detailed instructions for how-to-use, as well as installation and upgrade guidance.
This package allows you to manage user permissions and roles in a database.
Once installed you can do stuff like this:
// Adding permissions to a user
$user->givePermissionTo('edit articles');
// Adding permissions via a role
$user->assignRole('writer');
$role->givePermissionTo('edit articles');
Because all permissions will be registered on Laravel's gate, you can check if a user has a permission with Laravel's default can function:
$user->can('edit articles');
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
composer test
If you discover any security-related issues, please email security@spatie.be instead of using the issue tracker.
You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.
We publish all received postcards on our company website.
This package is heavily based on Jeffrey Way's awesome Laracasts lessons on permissions and roles. His original code can be found in this repo on GitHub.
Special thanks to Alex Vanderbist who greatly helped with v2, and to Chris Brown for his longtime support helping us maintain the package.
Special thanks to Caneco for the original logo.
The MIT License (MIT). Please see License File for more information.
.editorconfig
.gitattributes
.github/
dependabot.yml
FUNDING.yml
ISSUE_TEMPLATE/
1_Bug_report.yml
config.yml
workflows/
dependabot-auto-merge.yml
fix-php-code-style-issues.yml
phpstan.yml
run-tests.yml
test-cache-drivers.yml
update-changelog.yml
.gitignore
art/
logomark.png
logomark.svg
logomark@2x.png
logomark@3x.png
logomark@4x.png
palette/
100.png
200.png
300.png
400.png
500.png
600.png
700.png
800.png
900.png
README.md
socialcard.png
CHANGELOG.md
composer.json
config/
permission.php
database/
migrations/
add_teams_fields.php.stub
create_permission_tables.php.stub
docs/
_index.md
about-us.md
advanced-usage/
_index.md
cache.md
custom-permission-check.md
events.md
exceptions.md
extending.md
other.md
phpstorm.md
seeding.md
testing.md
timestamps.md
ui-options.md
uuid.md
basic-usage/
_index.md
artisan.md
basic-usage.md
blade-directives.md
direct-permissions.md
enums.md
middleware.md
multiple-guards.md
new-app.md
passport.md
role-permissions.md
super-admin.md
teams-permissions.md
wildcard-permissions.md
best-practices/
_index.md
performance.md
roles-vs-permissions.md
using-policies.md
changelog.md
images/
header.jpg
installation-laravel.md
introduction.md
prerequisites.md
questions-issues.md
sponsor-logo.png
support-us.md
upgrading.md
ide.json
LICENSE.md
phpstan-baseline.neon
phpstan.neon.dist
phpunit.xml.dist
pint.json
README.md
resources/
boost/
skills/
laravel-permission-development/
SKILL.md
src/
Commands/
AssignRoleCommand.php
CacheResetCommand.php
CreatePermissionCommand.php
CreateRoleCommand.php
ShowCommand.php
UpgradeForTeamsCommand.php
Contracts/
Permission.php
PermissionsTeamResolver.php
Role.php
Wildcard.php
DefaultTeamResolver.php
Events/
PermissionAttachedEvent.php
PermissionDetachedEvent.php
RoleAttachedEvent.php
RoleDetachedEvent.php
Exceptions/
GuardDoesNotMatch.php
PermissionAlreadyExists.php
PermissionDoesNotExist.php
RoleAlreadyExists.php
RoleDoesNotExist.php
TeamModelNotConfigured.php
TeamsNotEnabled.php
UnauthorizedException.php
WildcardPermissionInvalidArgument.php
WildcardPermissionNotImplementsContract.php
WildcardPermissionNotProperlyFormatted.php
Guard.php
helpers.php
Middleware/
PermissionMiddleware.php
RoleMiddleware.php
RoleOrPermissionMiddleware.php
Models/
Permission.php
Role.php
PermissionRegistrar.php
PermissionServiceProvider.php
Support/
Config.php
Traits/
HasAssignedModels.php
HasPermissions.php
HasRoles.php
RefreshesPermissionCache.php
WildcardPermission.php
tests/
Commands/
CommandTest.php
TeamCommandTest.php
GuardTest.php
Integration/
BladeTest.php
CacheTest.php
CustomGateTest.php
GateTest.php
MultipleGuardsTest.php
OctaneListenerTest.php
PermissionRegistrarTest.php
PolicyTest.php
RouteTest.php
WildcardRouteTest.php
Middleware/
PermissionMiddlewareTest.php
RoleMiddlewareTest.php
RoleOrPermissionMiddlewareTest.php
WildcardMiddlewareTest.php
Models/
PermissionTest.php
RoleTest.php
RoleWithNestingTest.php
TestPermissionEnum.php
TestRoleEnum.php
WildcardRoleTest.php
Pest.php
TestSupport/
ContentPolicy.php
resources/
views/
can.blade.php
guardHasAllRoles.blade.php
guardHasAllRolesArray.blade.php
guardHasAllRolesPipe.blade.php
guardHasAnyRole.blade.php
guardHasAnyRolePipe.blade.php
guardHasRole.blade.php
guardRole.blade.php
guardunlessrole.blade.php
hasAllRoles.blade.php
hasAnyRole.blade.php
haspermission.blade.php
hasRole.blade.php
role.blade.php
unlessrole.blade.php
TestCase.php
TestHelper.php
TestModels/
Admin.php
Client.php
Content.php
Manager.php
Permission.php
Role.php
RuntimeRole.php
SoftDeletingUser.php
Team.php
TestRolePermissionsEnum.php
User.php
UserWithoutHasRoles.php
WildcardPermission.php
Traits/
HasAssignedModelsTest.php
HasPermissionsTest.php
HasPermissionsWithCustomModelsTest.php
HasRolesTest.php
HasRolesWithCustomModelsTest.php
TeamHasPermissionsTest.php
TeamHasRolesTest.php
TeamScopeTest.php
WildcardHasPermissionsTest.phpFAQ
laravel-permission is a Claude Code plugin with 1 hand-picked skill for security work, indexed on Flowy. Install it with the command on its page. It includes laravel-permission-development. Its skills do not fire on their own yet. Request auto-invocation to have Flowy route them as you prompt. Free and open source.