https://github.com/statix-php/sentra
A lightweight Laravel roles and permissions package using Backed Enums
https://github.com/statix-php/sentra
laravel permissions roles roles-permissions
Last synced: about 1 month ago
JSON representation
A lightweight Laravel roles and permissions package using Backed Enums
- Host: GitHub
- URL: https://github.com/statix-php/sentra
- Owner: statix-php
- License: mit
- Created: 2024-12-13T07:04:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-13T22:12:37.000Z (over 1 year ago)
- Last Synced: 2025-04-14T11:56:17.729Z (12 months ago)
- Topics: laravel, permissions, roles, roles-permissions
- Language: PHP
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Sentra for Laravel
[](https://packagist.org/packages/statix/sentra)
A lightweight Laravel roles and permissions package using Backed Enums.
## Installation
You can install the package via composer:
```bash
composer require statix/sentra
```
You should publish the config file with the following command:
```bash
php artisan vendor:publish --tag="sentra"
```
This is the contents of the published config file:
```php
return [
/**
* The backed enum class that will be used to define your roles.
*/
'roles_enum' => 'App\Enums\Roles',
/**
* The backed enum class that will be used to define your permissions.
*/
'permissions_enum' => 'App\Enums\Permissions',
];
```
## Usage
To get started, create two string backed Enums - one of your roles and one for your permissions.
```bash
php artisan make:enum "App\Enums\Roles" --string
php artisan make:enum "App\Enums\Permissions" --string
```
If you create your enums in a different namespace or different name, be sure to update the `roles_enum` and `permissions_enum` in the `sentra.php` config file.
Then add the `AsRole` trait to your `Roles` enum.
```php