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…

这是什么?一个 Laravel 软件包,让你通过数据库管理用户权限和角色,并通过 Laravel 内置的 Gate 系统进行权限检查。
这是独立应用,还是我要添加到 Laravel 项目中的软件包?这是一个 Composer 软件包,需要安装到现有的 Laravel 应用中,而不是独立应用。
我该如何把它添加到 Laravel 项目中?通过 Composer 安装,然后按照软件包文档中的安装和升级指南操作(如迁移、发布配置等)。
除了 Laravel 本身,还需要别的东西吗?只需要一个带数据库的 Laravel 应用即可,因为角色和权限都存储在数据库中,并接入 Laravel 的授权系统。
安装之后,权限检查究竟是怎么运作的?所有权限都会注册到 Laravel 的 Gate 上,因此你可以使用 Laravel 标准的 `can()` 函数进行检查,而不需要专门的 API。
它和 Bouncer 或 Laratrust 有什么不同?它们都是 Laravel 的替代权限软件包,各有取舍:Bouncer 同样广受好评,Laratrust 增加了团队支持,Entrust 提供通配符模式匹配,而 laravel-permission 则专注于简单的、基于数据库的角色/权限模型,并与 Laravel 的 Gate 集成。
这个软件包的想法是从哪里来的?它很大程度上基于 Jeffrey Way 在 Laracasts 上关于权限和角色的课程,原始代码保存在一个单独的仓库中。
Creator
spatie
Size
3.2 MB
Stars
13K
Age
11y
Commits · 90 Days