Reusable RBAC system for Laravel apps

Maintainers

Package info

github.com/dhunganaroshan341/rbac-kit

pkg:composer/roshan-dhungana/rbac-kit

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-06 08:55 UTC

This package is auto-updated.

Last update: 2026-06-06 09:08:32 UTC


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.

  1. 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
  1. Develop the package locally (install into an app via path repository)
  • In your Laravel app's composer.json add 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
  1. Development notes and common commands
  • Ensure User model uses Spatie\Permission\Traits\HasRoles.
  • If php artisan vendor:publish --tag=rbac-kit-seeder returns 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
  1. Usage snippets
  • Register the policy (automatic if App\Models\Post exists) or add to AuthServiceProvider:
protected $policies = [
		\App\Models\Post::class => \RbacKit\Policies\PostPolicy::class,
];