PHPackages                             deifhelt/laravel-permissions-manager - 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. [Framework](/categories/framework)
4. /
5. deifhelt/laravel-permissions-manager

ActiveLibrary[Framework](/categories/framework)

deifhelt/laravel-permissions-manager
====================================

Roles and permissions manager for Laravel.

v1.1.0(1mo ago)027MITPHPPHP ^8.2CI passing

Since Jan 1Pushed 1mo agoCompare

[ Source](https://github.com/StevenU21/laravel-permissions-manager)[ Packagist](https://packagist.org/packages/deifhelt/laravel-permissions-manager)[ RSS](/packages/deifhelt-laravel-permissions-manager/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (26)Versions (4)Used By (0)

Laravel Permissions Manager
===========================

[](#laravel-permissions-manager)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4af16786b677c06de090f0e7f55eb1df15d4f8f37226e7191efe7518e376217b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465696668656c742f6c61726176656c2d7065726d697373696f6e732d6d616e616765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/deifhelt/laravel-permissions-manager)[![Total Downloads](https://camo.githubusercontent.com/8e337cf0133fc6f76e67547ebd9927357cf6db8710abd888d0ab97a200d7df04/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465696668656c742f6c61726176656c2d7065726d697373696f6e732d6d616e616765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/deifhelt/laravel-permissions-manager)[![License](https://camo.githubusercontent.com/844638336192826364dee907228e4ff4bb7e19049e0d1a7c2bd84dc489013d04/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465696668656c742f6c61726176656c2d7065726d697373696f6e732d6d616e616765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/deifhelt/laravel-permissions-manager)

A powerful wrapper around `spatie/laravel-permission` that manages permissions and roles through a simple configuration file.

Features
--------

[](#features)

- **Config-Driven**: Define permissions in `config/permissions.php`
- **Auto-CRUD Generation**: Automatically generates CRUD permissions
- **Smart Syncing**: Efficient database synchronization
- **Smart Translations**: Automatic human-readable labels
- **Policy Trait**: Simplify authorization with `HasPermissionCheck`

> **Note**: This package wraps `spatie/laravel-permission`. For advanced features like blade directives, middleware usage, caching, and direct role/permission assignment, see the [official Spatie documentation](https://spatie.be/docs/laravel-permission/v6/introduction).

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

[](#installation)

Install via Composer (Spatie Permission is included automatically):

```
composer require deifhelt/laravel-permissions-manager
```

Publish this package configuration:

```
php artisan vendor:publish --provider="Deifhelt\LaravelPermissionsManager\PermissionManagerServiceProvider"
```

This creates `config/permissions.php` (this package's permission definitions).

Publish Spatie Permission configuration and migrations:

```
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
```

This creates `config/permission.php` (Spatie's internal configuration) and migration files.

Clear config cache:

```
php artisan optimize:clear
```

Run migrations:

```
php artisan migrate
```

Add the `HasRoles` trait to your User model:

```
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;
}
```

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

[](#configuration)

### Standard CRUD Permissions

[](#standard-crud-permissions)

Define resources to auto-generate `read`, `create`, `update`, `destroy` permissions:

```
// config/permissions.php

'permissions' => [
    'users',
    'posts',
    'products',
],
```

This generates: `read users`, `create users`, `update users`, `destroy users`, etc.

### Special Permissions

[](#special-permissions)

Add custom actions that don't fit the CRUD pattern:

```
'special_permissions' => [
    'users' => ['ban', 'impersonate'],
    'system' => ['view-logs', 'maintenance-mode'],
],
```

This generates: `ban users`, `impersonate users`, `view-logs system`, etc.

### Super Admin (Bypass)

[](#super-admin-bypass)

Define roles that bypass all permission checks (Super Admin). These roles are defined separately because they inherently have all permissions.

```
// config/permissions.php
'super_admin_role' => 'admin', // Can be a string or array: ['admin', 'root']
```

**Note:**

1. The `permissions:sync` command automatically creates these roles in the database for you.
2. **Global Bypass**: This package registers a `Gate::before` callback. This ensures that `@can('any')`, `$user->can('any')`, and Policies automatically return `true` for these users, even if they have **0 permissions** in the database.

### Roles

[](#roles)

Define standard roles and assign their specific permissions:

```
'roles' => [
    // Manager - specific resources
    'manager' => [
        'users' => ['read', 'create', 'update'], // Specific actions
        'posts',                                  // All permissions for posts
    ],

    // Editor - explicit permission strings
    'editor' => [
        'read posts',
        'create posts',
        'update posts',
    ],
],

## Translations

Easily translate technical permissions (e.g., `create users`) into human-readable labels (e.g., "Crear Usuarios").

```bash
php artisan vendor:publish --tag=permissions-translations
```

Then use in your code:

```
use Deifhelt\LaravelPermissionsManager\Facades\Permissions;

```php
use Deifhelt\LaravelPermissionsManager\Facades\Permissions;

// Returns ['name' => 'create users', 'label' => 'Crear Usuarios']
$all = Permissions::getPermissionsWithLabels();

// Translate a single permission
echo Permissions::translate('create users');
```

See [Translations Documentation](docs/translations.md) for full details.

> **Note**: The system automatically respects your `config('app.locale')` and any runtime locale changes.

Sync Permissions
----------------

[](#sync-permissions)

After configuring your permissions and roles, sync them to the database:

```
php artisan permissions:sync
```

### Alternative: Using Database Seeders

[](#alternative-using-database-seeders)

For automated deployments, CI/CD pipelines, or NativePHP applications where you can't run artisan commands interactively, use the included seeder:

```
use Deifhelt\LaravelPermissionsManager\Database\Seeders\RolesAndPermissionsSeeder;

class DatabaseSeeder extends Seeder
{
    public function run(): void
    {
        $this->call(RolesAndPermissionsSeeder::class);
    }
}
```

This is particularly useful for [NativePHP desktop applications](https://nativephp.com/docs/desktop/2/publishing/building) where the database is created on first run.

Using with Policies
-------------------

[](#using-with-policies)

Use the `HasPermissionCheck` trait to simplify policy authorization:

```
use Deifhelt\LaravelPermissionsManager\Traits\HasPermissionCheck;

class PostPolicy
{
    use HasPermissionCheck;

    public function viewAny(User $user): bool
    {
        return $this->checkPermission($user, 'read posts');
    }

    public function update(User $user, Post $post): bool
    {
        // Checks permission AND ownership (user_id)
        return $this->checkPermission($user, 'update posts', $post);
    }
}
```

**Features:**

- **Admin Bypass**: Users with `admin` role automatically pass all checks
- **Permission Validation**: Verifies user has required permission
- **Ownership Check**: When passing a model, validates `user_id` matches

Documentation
-------------

[](#documentation)

- [Installation](docs/installation.md) - Complete setup guide including Laravel 11/12 middleware
- [Configuration &amp; Usage](docs/guide/README.md) - Deep dive into permissions, roles, and commands
- [Translations](docs/translations/README.md) - Translate permissions automatically
- [Policies](docs/policies/README.md) - Security patterns and trait usage

License
-------

[](#license)

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

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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 ~39 days

Total

3

Last Release

52d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

v1.0.1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1102199f2512f0899214ab072484185b6499dd1bf518e63a7e9403fe89afa135?d=identicon)[StevenU21](/maintainers/StevenU21)

---

Top Contributors

[![StevenU21](https://avatars.githubusercontent.com/u/89059916?v=4)](https://github.com/StevenU21 "StevenU21 (14 commits)")

---

Tags

laravel-frameworklaravel-packagepermission-managerspatie-laravel-permissionframeworklaravelmanagerrolespermissions

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/deifhelt-laravel-permissions-manager/health.svg)

```
[![Health](https://phpackages.com/badges/deifhelt-laravel-permissions-manager/health.svg)](https://phpackages.com/packages/deifhelt-laravel-permissions-manager)
```

###  Alternatives

[graham-campbell/manager

Manager Provides Some Manager Functionality For Laravel

39221.1M134](/packages/graham-campbell-manager)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[rebing/graphql-laravel

Laravel wrapper for PHP GraphQL

2.2k7.1M26](/packages/rebing-graphql-laravel)[graham-campbell/markdown

Markdown Is A CommonMark Wrapper For Laravel

1.3k7.1M64](/packages/graham-campbell-markdown)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

98548.9k4](/packages/defstudio-pest-plugin-laravel-expectations)

PHPackages © 2026

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