Download the PHP package binary-cats/laravel-rbac without Composer
On this page you can find all versions of the php package binary-cats/laravel-rbac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download binary-cats/laravel-rbac
More information about binary-cats/laravel-rbac
Files in binary-cats/laravel-rbac
Package laravel-rbac
Short Description Laravel enum-backed RBAC extension of spatie/laravel-permission
License MIT
Homepage https://github.com/binary-cats/laravel-rbac
Informations about the package laravel-rbac

Laravel RBAC
Enhance your Laravel with opinionated extension for spatie/laravel-permissions. Before your permission list grows and maintenance becomes an issue, this package offers simple way of defining roles and their permissions.
Installation
You can install the package via composer:
**N.B. If you are using
spatie/laravel-permission< version 7, you need to use 1.x version of the package:
You can publish the config file with:
This is the contents of the published config file:
You can publish the stub files with:
Usage
In a simple setup we usually have two basic parts of an RBAC: a permission and a role. Permissions are usually grouped by functional or business logic domain and a Role encapsulates them for a specific guard.
- Create Abilities
- Define Roles
- Connect the dots
Abilities
To avoid collision with spatie/laravel-permission we are going to use BackedEnum Ability enums to hold out enumerated permissions:
You can read more on using enums as permissions at the official docs.
To create an Ability:
This will generate a PostAbility in App\Abilities:
Default stub contains fairly standard CRUD enumeration, generated using the name of the ability. Feel free to publish the stubs and adjsut as needed.
Defined Roles
As the name suggests, a DefinedRole offers a mechanism to simplify the definition of all permissions needed for a given role.
To create an EditorRole run:
This will generate an EditorRole within App\Roles:
This class contains a (now testable!) configuration definition for the role and its web guard. Pretty neat!
We can now adjust it like so:
Now you are confident a specific role has specific permissions!
Connect the dots
Now that we have the abilities and roles, simply register role with rbac.php config:
When you run rbac:reset next time, your RBAC will be reset automatically.
Integration
I suggest adding the script to post-autoload-dump of your composer.json to make sure the RBAC is reset on every composer dump:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using 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.
Credits
- Cyrill N Kalita
- All Contributors
Support us
Binary Cats is a webdesign agency based in Illinois, US.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-rbac with dependencies
illuminate/contracts Version ^13.0
lorisleiva/laravel-actions Version ^2.8
spatie/laravel-package-tools Version ^1.16
spatie/laravel-permission Version ^8.3