PHPackages                             ngarak-dev/permissions-ui-wrapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ngarak-dev/permissions-ui-wrapper

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ngarak-dev/permissions-ui-wrapper
=================================

UI Wrapper for Spatie Laravel-Permission with Bootstrap, Tailwind, and Livewire support

v0.1.0(1y ago)010MITBladePHP ^8.1

Since May 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ngarak-dev/permissions-ui-wrapper)[ Packagist](https://packagist.org/packages/ngarak-dev/permissions-ui-wrapper)[ RSS](/packages/ngarak-dev-permissions-ui-wrapper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (11)Used By (0)

Permissions UI Wrapper
======================

[](#permissions-ui-wrapper)

A UI wrapper for Spatie Laravel-Permission with Bootstrap, Tailwind CSS, and Livewire support.

Features
--------

[](#features)

- Complete permission and role management UI
- Support for both Bootstrap and Tailwind CSS
- Reactive UI with Livewire components
- User role assignment interface
- Permission grouping for better organization
- Pagination, sorting, and filtering
- Comprehensive authorization controls
- Automatic migrations and config publishing
- Custom artisan commands for easy installation
- Customizable views and routes
- Seeders and factories for quick setup

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require ngarak-dev/permissions-ui-wrapper
```

The package automatically:

- Publishes the configuration file to `config/permissions-ui.php`
- Runs `composer dump-autoload` after installation or update
- Installs migrations when running `php artisan migrate`

### Manual Installation

[](#manual-installation)

If you prefer manual installation, you can use the provided artisan commands:

```
# Install everything (config & migrations)
php artisan permissions-ui:install

# Install both standard and Livewire components
php artisan permissions-ui:install --with-livewire

# Install only Livewire components
php artisan permissions-ui:install --with-livewire-only

# Install only migrations
php artisan permissions-ui:migrations
```

These commands will automatically publish Spatie Permission package migrations before installing the package's own migrations, ensuring proper setup sequence.

You can use the `--force` flag with either command to overwrite existing files.

### Publishing All Components

[](#publishing-all-components)

If you want to make all components available in your application for customization, you can use the publish-all command:

```
# Publish all components (controllers, views, providers, etc.)
php artisan permissions-ui:publish-all

# Include Livewire components
php artisan permissions-ui:publish-all --with-livewire

# Force overwrite existing files
php artisan permissions-ui:publish-all --force
```

This will publish:

- Controllers (to `app/Http/Controllers/PermissionsUiWrapper`)
- Livewire components (to `app/Http/Livewire/PermissionsUiWrapper`)
- Providers (to `app/Providers/PermissionsUiWrapper`)
- Views (to `resources/views/{your-namespace}`)
- Config and migrations

### Customizing the View Namespace

[](#customizing-the-view-namespace)

By default, the package uses `permission-wrapper` as the namespace for views. You can change this in the config:

```
// config/permissions-ui.php
'views' => [
    'namespace' => 'your-custom-namespace', // Default: 'permission-wrapper'
],
```

After changing this, you should re-publish the views to the new namespace location:

```
php artisan permissions-ui:install --force
```

This will publish the views to `resources/views/your-custom-namespace/`.

### Template Namespace Consistency

[](#template-namespace-consistency)

All templates in the package use the configurable namespace for includes and extends:

```
@php
$namespace = config('permissions-ui.views.namespace', 'permission-wrapper');
@endphp

@extends($namespace . '::layouts.app')
```

This ensures that all view resolution is consistent with your configured namespace, even for deeply nested includes and components.

### Setting up Super User

[](#setting-up-super-user)

After installation, you should set up a super user who can manage permissions and roles:

```
# Set an existing user as super user
php artisan permissions-ui:super-user {userId}

# Create a new user as super user
php artisan permissions-ui:super-user --create
```

The new command allows:

- Setting an existing user as a super user with full permissions management access
- Creating a new user and assigning the super user role
- Automatically creating the super admin role if it doesn't exist
- Assigning all permissions to the role (optional)

### Using Seeders and Factories

[](#using-seeders-and-factories)

The package provides seeders and factories to quickly set up roles and permissions for testing or initial production setup:

```
# Publish seeders and factories
php artisan permissions-ui:seeders

# Publish only seeders
php artisan permissions-ui:seeders --no-factories

# Publish only factories
php artisan permissions-ui:seeders --no-seeders
```

Once published, you can use the seeders in your application:

```
# Run the permission and role seeder
php artisan db:seed --class=PermissionRoleSeeder
```

Seeders include:

- Common CRUD permissions for resources like users, roles, posts, etc.
- Predefined roles (Super Admin, Admin, Editor, Author, Moderator, User)
- Proper permission assignments to each role

You can configure the seeder behavior in the `permissions-ui.php` config file under the `seeder` section:

```
'seeder' => [
    // Whether to clear existing permissions and roles before seeding
    'clear_before_seeding' => false,

    // Whether to create random permissions in addition to the defined ones
    'create_random_permissions' => false,

    // Whether to create random roles in addition to the defined ones
    'create_random_roles' => false,

    // If set, this user ID will automatically be assigned the Super Admin role
    'super_admin_user_id' => null,
],
```

Configuration
-------------

[](#configuration)

If you want to manually publish the configuration:

```
php artisan vendor:publish --tag="permissions-ui-config"
```

### Views and Routes

[](#views-and-routes)

The `permissions-ui:install` command automatically:

1. Copies all view files to `resources/views/permission-wrapper/` in your application
2. Publishes routes to `routes/permission-wrapper.php`
3. Adds an include statement to your application's `routes/web.php` file

This approach allows you to customize views and routes directly in your application without modifying the package files.

If you prefer to manually publish the views:

```
php artisan vendor:publish --tag="permissions-ui-views"
```

### Customizing Views

[](#customizing-views)

All published views are in the `resources/views/permission-wrapper` directory, organized by UI framework (bootstrap/tailwind) and feature type. You can modify these views directly without affecting the package.

### Customizing Routes

[](#customizing-routes)

After installation, you'll find a `permission-wrapper.php` file in your routes directory. You can modify these routes as needed. To prevent the package from loading its internal routes, set the following in your config:

```
// config/permissions-ui.php
'disable_package_routes' => true,
```

Livewire Components
-------------------

[](#livewire-components)

This package includes Livewire components for reactive permission management - with livewire make sure to change and use tailwind in `permission-ui.php`:

- `PermissionManager`: A component for managing permissions with CRUD operations
- `RolePermissionMatrix`: An interactive matrix for assigning permissions to roles

### Installation with Livewire

[](#installation-with-livewire)

You can choose to install Livewire components during the installation process:

```
# Install both standard and Livewire components
php artisan permissions-ui:install --with-livewire

# Install only Livewire components (without standard UI)
php artisan permissions-ui:install --with-livewire-only
```

If you install with the `--with-livewire-only` option, only Livewire routes and views will be published.

### Accessing Livewire Components

[](#accessing-livewire-components)

After installation, the Livewire components are accessible at:

- Permission Manager: `/permissions/livewire/permissions`
- Role Permission Matrix: `/permissions/livewire/roles-matrix`

The prefix can be customized in the configuration file.

### Running Migrations

[](#running-migrations)

Run migrations to add permission groups:

```
php artisan migrate
```

Spatie Laravel-Permission Integration
-------------------------------------

[](#spatie-laravel-permission-integration)

This package provides a user interface for the [Spatie Laravel-Permission](https://github.com/spatie/laravel-permission) package. Here's a comprehensive guide to working with the underlying Spatie features.

### Basic Setup

[](#basic-setup)

Ensure your `User` model implements the `HasRoles` trait:

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;

    // ...
}
```

### Working with Permissions

[](#working-with-permissions)

#### Checking Permissions

[](#checking-permissions)

```
// Check if a user has a specific permission
if ($user->hasPermissionTo('edit articles')) {
    // ...
}

// Check if a user has any of the permissions
if ($user->hasAnyPermission(['edit articles', 'publish articles'])) {
    // ...
}

// Check if a user has all permissions
if ($user->hasAllPermissions(['edit articles', 'publish articles'])) {
    // ...
}
```

#### Using Middleware

[](#using-middleware)

This package automatically registers Spatie's middleware. Use them in your routes:

```
Route::group(['middleware' => ['permission:publish articles']], function () {
    // Routes accessible only to users with the 'publish articles' permission
});

Route::group(['middleware' => ['role:admin']], function () {
    // Routes accessible only to users with the 'admin' role
});

Route::group(['middleware' => ['role_or_permission:admin|edit articles']], function () {
    // Routes accessible to users with either 'admin' role or 'edit articles' permission
});
```

#### Blade Directives

[](#blade-directives)

Use Spatie's Blade directives in your views:

```
@role('admin')
    Admin content here
@endrole

@hasrole('writer')
    Writer content here
@endhasrole

@hasanyrole(['writer', 'editor'])
    Writer or Editor content here
@endhasanyrole

@hasallroles(['writer', 'admin'])
    Writer and Admin content here
@endhasallroles

@unlessrole('admin')
    Non-admin content here
@endunlessrole

@can('edit articles')
    Edit
@endcan

@canany(['edit articles', 'delete articles'])

        Actions

            @can('edit articles')
                Edit
            @endcan
            @can('delete articles')

                    @csrf
                    @method('DELETE')
                    Delete

            @endcan

@endcanany
```

### Working with Roles

[](#working-with-roles)

#### Assigning Roles

[](#assigning-roles)

```
// Assign a role to a user
$user->assignRole('writer');

// Assign multiple roles
$user->assignRole(['writer', 'admin']);

// Alternative syntax
$user->assignRole('writer', 'admin');
```

#### Revoking Roles

[](#revoking-roles)

```
// Remove a role from a user
$user->removeRole('writer');

// Remove multiple roles
$user->removeRole(['writer', 'admin']);
```

#### Syncing Roles

[](#syncing-roles)

```
// Remove all roles and assign the given roles
$user->syncRoles(['writer', 'admin']);
```

#### Checking Roles

[](#checking-roles)

```
// Check if a user has a role
if ($user->hasRole('writer')) {
    // ...
}

// Check if a user has any of the roles
if ($user->hasAnyRole(['writer', 'admin'])) {
    // ...
}

// Check if a user has all roles
if ($user->hasAllRoles(['writer', 'admin'])) {
    // ...
}
```

### Permission Groups

[](#permission-groups)

This package extends Spatie's permissions with a grouping feature. The groups are defined in the configuration:

```
'permission_groups' => [
    'user' => [
        'label' => 'User Management',
        'description' => 'Permissions related to user management',
    ],
    // Add more groups...
],
```

You can assign a permission to a group when creating or editing it through the UI, which helps organize permissions logically.

### Super Admin Role

[](#super-admin-role)

By default, this package looks for a role specified in the config (`permissions_manager_role`) to grant full access to the permissions management UI:

```
'permissions_manager_role' => 'super-admin',
```

Users with this role will have full access to create, edit, and delete roles and permissions.

### Caching

[](#caching)

Spatie Laravel-Permission uses caching to speed up permission checks. The cache is automatically reset when:

- Permissions or roles are created, updated, or deleted through the UI
- Permission/role relationships are modified

If you need to manually clear the cache:

```
app()->make(\Spatie\Permission\PermissionRegistrar::class)->forgetCachedPermissions();
```

### Database Seeding

[](#database-seeding)

This package provides predefined seeders that can be published and customized. To seed a production environment with initial permissions and roles:

```
php artisan db:seed --class=PermissionRoleSeeder
```

The seeder will create common permissions, roles, and assign them appropriately.

### Multiple Guards

[](#multiple-guards)

Spatie Laravel-Permission supports multiple authentication guards. This UI package primarily works with the 'web' guard, but the underlying Spatie functionality supports custom guards:

```
// Creating a role with a custom guard
$adminRole = Role::create(['name' => 'admin', 'guard_name' => 'api']);

// Assigning a role with a custom guard
$user->assignRole('admin', 'api');
```

### UUID Support

[](#uuid-support)

If your application uses UUIDs instead of auto-incrementing IDs, make the following changes after installing:

1. Publish the migrations with `php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations"`
2. Modify the published migrations to use UUID columns
3. Update your model implementations

Usage
-----

[](#usage)

### Select UI Framework

[](#select-ui-framework)

Choose between Bootstrap and Tailwind UI in the config:

```
// config/permissions-ui.php
return [
    'ui_framework' => 'bootstrap', // or 'tailwind'
];
```

### Permission Groups

[](#permission-groups-1)

Organize permissions into logical groups:

```
'permission_groups' => [
    'user' => [
        'label' => 'User Management',
        'description' => 'Permissions related to user management',
    ],
    // Add more groups...
],
```

### Routes

[](#routes)

The package registers the following routes by default:

- `/permissions` - View all permissions
- `/permissions/create` - Create a new permission
- `/permissions/{permission}/edit` - Edit a permission
- `/permissions/roles` - View all roles
- `/permissions/roles/create` - Create a new role
- `/permissions/roles/{role}/edit` - Edit a role and assign permissions
- `/permissions/users` - Manage user roles
- `/permissions/users/{user}/edit` - Edit roles for a specific user

### Authorization

[](#authorization)

By default, only users with the role specified in `permissions_manager_role` config (default: 'super-admin') can access these routes. You can customize this in the configuration file.

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance49

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

10

Last Release

376d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c0572a40244530b70a2c4fc907ca8b797efa0dd22cef7e44c8256d6fdcc8c1a?d=identicon)[ngarak-dev](/maintainers/ngarak-dev)

---

Top Contributors

[![ngarak-dev](https://avatars.githubusercontent.com/u/26841409?v=4)](https://github.com/ngarak-dev "ngarak-dev (29 commits)")

---

Tags

laraveluilivewirerolespermissionstailwindbootstrap

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ngarak-dev-permissions-ui-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/ngarak-dev-permissions-ui-wrapper/health.svg)](https://phpackages.com/packages/ngarak-dev-permissions-ui-wrapper)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6712.1k2](/packages/hasinhayder-tyro)[tonystore/livewire-permission-manager

Package that provides a graphical interface to manage roles and permissions.

171.0k](/packages/tonystore-livewire-permission-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
