codersandip/role-permission-visualizer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

codersandip/role-permission-visualizer

最新稳定版本:v1.0.0

Composer 安装命令:

composer require codersandip/role-permission-visualizer

包简介

A visual mapping and conflict detection tool for Laravel Roles & Permissions

README 文档

README

A developer-friendly UI tool to visualize and manage roles, permissions, and users in an interactive graph-based interface. This package extends the functionality of the spatie/laravel-permission ecosystem, providing immediate insights and conflict detection.

Package Preview

📌 Requirements

  • PHP ^8.0.2
  • Laravel 8.x | 9.x | 10.x | 11.x | 12.x
  • spatie/laravel-permission ^5.0 or ^6.0

🚀 Features

  • Interactive Graph Canvas: Navigate your Access Control List visually using React Flow.
  • Color-Coded Nodes: Easily identify Users (orange), Roles (blue), and Permissions (green).
  • Intelligent Conflict Detection:
    • Spots and alerts you when a user has conflicting roles.
    • Detects redundant (duplicate) permission inheritance across multiple roles.
  • Filtering System: Toggle visibility between users, roles, and permissions in real-time.
  • Exporting: Download an image (PNG) snapshot of your entire RBAC landscape.

🛠 Installation

You can install the package via composer into your local project. Since the package is unpublished, you'll install it from a local file path or custom VCS repository:

composer require codersandip/role-permission-visualizer

Publish the config and the compiled frontend assets to your public directory:

php artisan vendor:publish --tag=visualizer-config
php artisan vendor:publish --tag=visualizer-assets

⚙️ Configuration

The package comes with sensible defaults. In your config/permission-visualizer.php, you can customize:

return [
    'route' => [
        'prefix' => 'role-permission-visualizer',
        'middleware' => ['web', 'visualizer.access'],
    ],

    // Overwrite the user model manually, or leave null to automatically extract it from auth.providers.
    'user_model' => null,

    'cache' => [
        'enabled' => false,
        'ttl' => 3600, // 1 hour caching for immense production graphs
    ],
];

🔒 Access Control (Authorization)

By default, the dashboard is only available when the application environment is set to local.

If you want to view it in production, or restrict who can access it locally, you should define a built-in Gate in your App\Providers\AuthServiceProvider boots method:

use Illuminate\Support\Facades\Gate;

public function boot()
{
    $this->registerPolicies();

    Gate::define('viewRolePermissionVisualizer', function ($user) {
        // e.g., Only allow Super Admins
        return $user->hasRole('Super Admin');
    });
}

🌐 Usage

Simply navigate to:

http://your-app.test/role-permission-visualizer

Use the Sidebar to tweak visibility or evaluate conflicts. Clicking over any node will invoke the contextual Inspector to observe exact DB values mapping.

🏗 Development & Modification

Because this package contains a bundled React frontend, if you modify the interface inside resources/js, you need to recompile the assets:

cd vendor/codersandip/role-permission-visualizer
npm install
npm run build

Then republish the assets back to the parent Laravel application.

🧪 Testing

To run the package's testing suite locally:

composer test
# or
./vendor/bin/phpunit

📄 License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-01