承接 budhaspec/rolepermission 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

budhaspec/rolepermission

Composer 安装命令:

composer require budhaspec/rolepermission

包简介

Allow admin to create module/sub module and assign a permissions to user. User can then access module as per the permission assigned to them.

README 文档

README

Please check the official laravel installation guide for server requirements before you start. Official Documentation

About RolePermission

A lightweight and customizable Role & Permission management system tailored for Laravel admin panels—built with no third-party dependencies.
You can define your own modules and sub-modules, create custom roles, and assign specific permissions to those roles.
Once permissions are set, simply assign the role to a user to control access.

Installation

Install the package via Composer:

composer require budhaspec/rolepermission

Run the database migrations (ensure your .env file is configured properly):

php artisan migrate

Publish the public assets:

php artisan vendor:publish --tag=public

Update user model as below.

use Budhaspec\Rolepermission\Models\Role;

Add 'role_id' in $fillable array.

Add below relationship.

public function role() {
    return $this->belongsTo(Role::class, 'role_id');
}

Start the local development server:

php artisan serve

You can now access the server at http://127.0.0.1:8000/

Usage

Middleware & Route Protection

Configure middleware in bootstrap/app.php

use Budhaspec\Rolepermission\Http\middleware\CheckPermission;

->withMiddleware(function (Middleware $middleware) {
      $middleware->alias([
          'role-permission' => CheckPermission::class,
      ]);
  })

Wrap any routes you want protected by roles and permissions inside the role-permission middleware:

Route::middleware(['auth', 'role-permission'])->group(function () {
	  Route::get('/product/list', fn () => 'Outer Product List')->name('product.list');
    Route::get('/product/add', fn () => 'Outer Product add')->name('product.add');
});

Only users with the appropriate role and permission will be able to access the routes inside this group.

Modules

Manage modules and sub-modules from:

http://127.0.0.1:8000/modules

This section allows you to define features (modules) and their actions (sub-modules) that need to be permission-controlled.

Roles

Manage roles and assign permissions via:

http://127.0.0.1:8000/roles

From here, you can:

  • Create and edit roles
  • Assign module and sub-module permissions to roles
  • Assign roles to users

Permissions Mapping Convention

Important: THE NAMED ROUTE MUST MATCH THE MODULE.SUB-MODULE NAME; otherwise, IT WON'T WORK.

From the roles section you can manage roles, Assign permissions (module/sub module) to specific role by clicking on 'Assign Permission' button.

You can assign that Role to specific users for given a grant of that module/sub module.

Suppose product is module and list, add, edit and delete are sub modules assigned to manager role.
Manager role assigned to budha.test@gmail.com user then that user can access product and it's
sub module list, add, edit and delete routes.

 Consider the below test cases for product module.

 Correct Format:
 	Route::get('/product/list', fn () => 'Product List')->name('product.list');

 Incorrect Formats:
  	Route::get('/product/list', fn () => 'Product List')->name('product.listing');  // Invalid
	  Route::get('/product/list', fn () => 'Product List')->name('products');         // Invalid

 ------------------------------------------------------------------------------------------------------------------------

 | Module  | Sub-Module | Valid Route Name | Invalid Examples                      |
 | ------- | ---------- | ---------------- | ------------------------------------- |
 | product | list       | `product.list`   | `product.listing`, `products.listing` |
 | product | add        | `product.add`    | `product.create`, `product.insert`    |
 | product | edit       | `product.edit`   | `product.update`                      |
 | product | delete     | `product.delete` | `product.destroy`, `product.remove`   |

 Important: In short, named route must be module.sub module name like 'product.list' then it will work.

 Example:
	If the module is product and sub-module is edit, then the named route must be product.edit

	Route::get('/product/{id}/edit', fn () => 'Edit Product')->name('product.edit'); // ✅ Valid

budhaspec/rolepermission 适用场景与选型建议

budhaspec/rolepermission 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 budhaspec/rolepermission 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 budhaspec/rolepermission 我们能提供哪些服务?
定制开发 / 二次开发

基于 budhaspec/rolepermission 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-07