laravilt/users
Composer 安装命令:
composer require laravilt/users
包简介
User and Role management plugin for Laravilt - Full RBAC system with impersonation support
README 文档
README
Laravilt Users
Complete User and Role management plugin for Laravilt with full RBAC (Role-Based Access Control) system and impersonation support.
Features
User Management
- Full CRUD Operations - Create, read, update, and delete users
- Avatar Support - Optional user avatars with fallback to UI Avatars
- Email Verification - Track email verification status
- Role Assignment - Assign multiple roles to users
- Search & Filters - Filter users by role, search by name/email
Role Management
- Complete RBAC - Full Role-Based Access Control system
- Permission Groups - Permissions grouped by resource
- Bulk Selection - Select all permissions for a resource
- Guard Support - Multiple auth guards support
Impersonation
- User Impersonation - Login as any user for debugging/support
- Session Preservation - Original session saved during impersonation
- Banner Notification - Visual indicator when impersonating
- Security Controls - Cannot impersonate self or super admins
Localization
- Multi-language - Full English and Arabic translations
- RTL Support - Right-to-left layout support for Arabic
- Translatable Labels - All fields, actions, and messages translated
Requirements
- PHP 8.3+
- Laravel 12+
- Laravilt 1.0+
- Spatie Laravel Permission 6.0+
Installation
composer require laravilt/users
The service provider is auto-discovered and will register automatically.
Run Migrations
php artisan migrate
Install Plugin
php artisan laravilt:users:install
This command will:
- Publish configuration file
- Set up default permissions
- Create default roles (Super Admin, Admin, User)
Configuration
Publish the configuration file:
php artisan vendor:publish --tag=laravilt-users-config
Configure in config/laravilt-users.php:
return [ // Default guard for permissions 'guard_name' => 'web', // Features (opt-in) 'features' => [ 'impersonation' => false, // Enable user impersonation 'avatar' => false, // Enable user avatars 'teams' => false, // Enable team support 'email_verification' => true, ], // Navigation settings 'navigation' => [ 'group' => 'Users & Roles', 'sort' => 1, ], // Impersonation settings 'impersonation' => [ 'redirect_to' => '/admin', 'leave_redirect_to' => '/admin', ], ];
Usage
Register Plugin with Panel
use Laravilt\Users\UsersPlugin; class AdminPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel ->plugins([ UsersPlugin::make() ->navigationGroup('Settings') ->navigationSort(10) ->avatar() // Enable avatars ->impersonation(), // Enable impersonation ]); } }
Plugin Methods
UsersPlugin::make() // Navigation ->navigationGroup('Custom Group') // Set navigation group ->navigationSort(5) // Set navigation order // Features (opt-in) ->avatar() // Enable avatar feature ->impersonation() // Enable impersonation feature
User Model Setup
Add the required traits to your User model:
use Laravilt\Users\Concerns\HasRolesAndPermissions; use Laravilt\Users\Concerns\HasAvatar; class User extends Authenticatable { use HasRolesAndPermissions; use HasAvatar; // Optional, for avatar support // For impersonation support public function canImpersonate(): bool { return $this->hasRole('super_admin'); } public function canBeImpersonated(): bool { return !$this->hasRole('super_admin'); } }
Setting Up Permissions
Run the setup command to create permissions for all resources:
php artisan laravilt:secure
This creates permissions like:
view_any_user,view_user,create_user,update_user,delete_userview_any_role,view_role,create_role,update_role,delete_role
Impersonation
Enable Impersonation
UsersPlugin::make()->impersonation()
Add Middleware
Add the impersonation banner middleware to your panel:
use Laravilt\Users\Http\Middleware\ImpersonationBanner; $panel->middleware([ ImpersonationBanner::class, ]);
Stop Impersonation
Users can stop impersonation via:
- The banner "Stop Impersonation" button
- Route:
GET /admin/impersonation/leave
Resources
UserResource
Manages users with:
- Avatar (optional)
- Name and Email
- Password management
- Role assignment
- Email verification status
- Created/Updated timestamps
RoleResource
Manages roles with:
- Role name
- Guard name
- Permission assignment (grouped by resource)
- User count
Translations
All strings are translatable. Translation files are located in:
lang/en/users.php- English translationslang/ar/users.php- Arabic translations
Documentation
Comprehensive documentation is available in the docs/ directory:
Testing
composer test
Code Style
composer format
Static Analysis
composer analyse
Contributing
Please see CONTRIBUTING.md for details.
Security
If you discover any security-related issues, please email info@3x1.io instead of using the issue tracker.
Changelog
Please see CHANGELOG.md for recent changes.
License
The MIT License (MIT). Please see License File for more information.
Credits
- Fady Mondy
- Spatie for Laravel Permission
- All Contributors
Sponsors
Support this project via GitHub Sponsors.
laravilt/users 适用场景与选型建议
laravilt/users 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「acl」 「Users」 「laravel」 「roles」 「permissions」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 laravilt/users 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravilt/users 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 laravilt/users 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Laravel Multiauth package
Debugging a problem and need to login as one of your customers? This allows you to authenticate as any of your customers.
A trait for Laravel models which have many users with roles.
The library provides a flexible way to add role-based access control management to CakePHP 3.x
Authorization package for ARCANESOFT/Foundation.
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-21
