roshan-dhungana / rbac-kit
Reusable RBAC system for Laravel apps
v1.0.0
2026-06-06 08:55 UTC
Requires
- php: >=8.1
- illuminate/support: ^9.0 || ^10.0 || ^11.0
- spatie/laravel-permission: ^6.0
README
A reusable Role-Based Access Control (RBAC) system for Laravel applications. This package provides a structured and scalable way to manage roles and permissions across multiple Laravel projects.
It is built on top of Spatie Laravel Permission and adds opinionated defaults, seeders, and a simplified integration layer for faster setup.
Features
- Predefined roles and permissions structure
- Automatic seeding for initial RBAC setup
- Middleware for role and permission checks
- Blade directives for role-based UI control
- API-ready integration with Laravel Sanctum
- Clean and reusable architecture for multiple projects
- Built on top of Spatie Laravel Permission
Requirements
- PHP 8.1 or higher
- Laravel 10 or 11
- Spatie Laravel Permission package
Installation
Install via Composer:
composer require roshan-dhungana/rbac-kit
Compatibility
- PHP: 8.1 and above
- Laravel: 10 and 11 (backwards compatibility may exist for other 9.x/10.x versions)
If you'd like, I can add installation examples, config publishing, and quick usage snippets next.
Quickstart — Run & Develop
These steps cover both consuming the package in a Laravel app and developing it locally.
- From a new or existing Laravel application (recommended)
# In your Laravel app root composer require roshan-dhungana/rbac-kit composer require spatie/laravel-permission php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" php artisan migrate # Publish the RBAC Kit seeder into your app php artisan vendor:publish --tag=rbac-kit-seeder # Seed roles & permissions php artisan db:seed --class=RolePermissionSeeder # Run the app php artisan serve
- Develop the package locally (install into an app via path repository)
- In your Laravel app's
composer.jsonadd a path repository pointing to this package (adjust path):
"repositories": [ { "type": "path", "url": "../packages/rbac-kit", "options": { "symlink": true } } ]
Then run:
composer require roshan-dhungana/rbac-kit:@dev composer install php artisan vendor:publish --tag=rbac-kit-seeder php artisan db:seed --class=RolePermissionSeeder php artisan serve
- Development notes and common commands
- Ensure
Usermodel usesSpatie\Permission\Traits\HasRoles. - If
php artisan vendor:publish --tag=rbac-kit-seederreturns nothing, run it from your Laravel application's root (not inside the package repo). - To remove accidental
vendor/commits:
git rm -r --cached vendor
git commit -m "Remove vendor from tracking"
git push origin main
- Usage snippets
- Register the policy (automatic if
App\Models\Postexists) or add toAuthServiceProvider:
protected $policies = [ \App\Models\Post::class => \RbacKit\Policies\PostPolicy::class, ];