laravel-permission README

The project's README from github.com/spatie/laravel-permission. As one markdown file: README.md.

Logo for laravel-permission

Associate users with permissions and roles

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Documentation, Installation, and Usage Instructions

See the documentation for detailed instructions for how-to-use, as well as installation and upgrade guidance.

What It Does

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');

Support us

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.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Testing

composer test

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Postcardware

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.

Credits

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.

Alternatives

License

The MIT License (MIT). Please see License File for more information.

laravel-permission (spatie/laravel-permission)

Searching Database…

What is this?A Laravel package that lets you manage user permissions and roles through your database, and checks them via Laravel's built-in Gate system.
Is this a standalone app or a package I add to my Laravel project?It's a Composer package you install into an existing Laravel application, not a standalone app.
How do I add it to my Laravel project?Install it via Composer and follow the package's documentation for installation and upgrade guidance (migrations, config publishing, etc.).
Do I need anything beyond Laravel itself?Just a Laravel app with a database, since roles and permissions are stored there and hooked into Laravel's authorization system.
How do permission checks actually work once it's installed?All permissions get registered on Laravel's Gate, so you check them using Laravel's standard `can()` function instead of a custom API.
How is this different from Bouncer or Laratrust?They are alternative Laravel permission packages with different tradeoffs: Bouncer is also well-regarded, Laratrust adds team support, and Entrust offers wildcard pattern matching, while laravel-permission focuses on a simple database-backed role/permission model integrated with Laravel's Gate.
Where did the idea for this package come from?It's heavily based on Jeffrey Way's Laracasts lessons on permissions and roles, with the original code available in a separate repo.
Creator
spatie
Size
3.2 MB
Stars
13K
Age
11y
Commits · 90 Days