PHPackages                             gurinder/laravel-acl - 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. gurinder/laravel-acl

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

gurinder/laravel-acl
====================

Laravel Roles And Permissions with UI

1.0.11(7y ago)0210MITPHPPHP ^7.1.3

Since Jun 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/gurindersingh/laravel-acl)[ Packagist](https://packagist.org/packages/gurinder/laravel-acl)[ Docs](https://github.com/gurindersingh/laravel-aps)[ RSS](/packages/gurinder-laravel-acl/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (11)Versions (13)Used By (0)

Laravel Access Control List (ACL) System
========================================

[](#laravel-access-control-list-acl-system)

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

[](#installation)

### Step 1

[](#step-1)

Include via Composer

```
composer require gurinder/laravel-acl
```

### Step 2

[](#step-2)

Publish the migration, views(If required to customize), config(Optional)

```
php artisan vendor:publish --tag="acl::migrations"

// Optional
php artisan vendor:publish --tag="acl::views"

// Optional
php artisan vendor:publish --tag="acl::config"
```

### Step 3

[](#step-3)

Run migration

```
php artisan migrate
```

Step 4 - Config File
--------------------

[](#step-4---config-file)

Configuration file information

```
return [

    // Cache key to store acl data
    'cache_key' => 'gurinder.laravel-acl',

    // Cache Exiration time
    'cache_expiration_time' => 60 * 24,

    // Route prefix e.g. 'example.com/admin
    'route_prefix' => 'admin',

    // Route name as e.g use -> route('admin.roles.index')
    'route_as' => 'admin.',

    // Master roles - All new permission will be added to these roles automatically.
    'master_roles' => ['admin'],

    // Roles which are not editable
    'freezed_roles' => ['admin'],

    // Permissions which are not editable
    'freezed_permissions' => ['manage-acl', 'manage-users'],

    // Link back to dashboard or anywhere else
    'back_link' => [
        'label' => 'Dashboard',
        'url'   => '/home'
    ],

    // Search column on user models
    'user_search_columns' => [
        'id',
        'name',
        'email'
    ]

];
```

Step 5 - Add function
---------------------

[](#step-5---add-function)

Add required function to your `helpers.php` file

```
if (!function_exists('isAdmin')) {

    /**
     * Check if user is admin admin
     *
     * @param \App\Models\User|null $user
     * @return bool
     */
    function isAdmin(\App\Models\User $user = null)
    {
        return $user ? $user->isAdmin() : (auth()->check() && auth()->user()->isAdmin());
    }

}
```

Step 6 - Add middleware
-----------------------

[](#step-6---add-middleware)

```
protected $routeMiddleware = [
    // ...
    'permissions'   => \Gurinder\LaravelAcl\Middlewares\PermissionsMiddleware::class,
    'roles'         => \Gurinder\LaravelAcl\Middlewares\RolesMiddleware::class
];
```

Usage
-----

[](#usage)

Add `AclGuarded` Trait to your user model &amp; `isAdmin()` to your `User` model

```
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Gurinder\LaravelAcl\Traits\AclGuarded;

class User extends Authenticatable
{
    use Notifiable, AclGuarded;

    ...
}
```

Check if user has Role or Permission

```
Gurinder\LaravelAcl\Package\Models\Role
Gurinder\LaravelAcl\Package\Models\Permission

$user->hasRole($role) // $role can be string, ID, or Role Model instance
$user->hasPermission($permission) // $permission can be string, ID, or Permission Model instance
```

You can also use permissions in blade directives

```
@can('manage-acl')
    // The Current User Can Manage Acl
@elsecan('manage-users')
    // The Current User Can Manage Users
@endcan

// OR

@if (Auth::user()->can('manage-acl'))
    // The Current User Can Manage Acl
@endif
```

Database Seeding
----------------

[](#database-seeding)

Make factories for roles and models

```
use Faker\Generator as Faker;

$factory->define(\Gurinder\LaravelAcl\Package\Models\Role::class, function (Faker $faker) {
    return [
        'name' => $faker->word
    ];
});

$factory->define(\Gurinder\LaravelAcl\Package\Models\Permission::class, function (Faker $faker) {
    return [
        'name' => $faker->word
    ];
});
```

Make Seeder Class

```
use Gurinder\LaravelAcl\Package\Models\Permission;
use Gurinder\LaravelAcl\Package\Models\Role;
use Illuminate\Database\Seeder;

class AccessControlListTableSeeder extends Seeder
{

    protected $roles = [ 'admin','editor'];

    protected $permissions = [
        'manage users',
        'manage acl',
        'manage posts'
    ];

    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $roles = $this->seedRoles();
        $permissionsIds = $this->seedPermissions();
        $roles['admin']->syncPermissions($permissionsIds);
    }

    /**
     * @return array
     */
    protected function seedRoles()
    {
        $roles = [];

        foreach ($this->roles as $role) {
            $role = factory(Role::class)->create(['name' => $role, 'slug' => str_slug($role)]);
            $roles[$role->slug] = $role;
        }

        return $roles;
    }

    protected function seedPermissions()
    {
        $ids = [];

        foreach ($this->permissions as $label) {
            $ids[] = factory(Permission::class)->create(['name' => $label, 'slug' => str_slug($label)])->id;
        }

        return $ids;
    }
}
```

### In Routes

[](#in-routes)

```
Route::group(['middleware' => ['role:super-admin']], function () {
    //
});

Route::group(['middleware' => ['permission:manage-users']], function () {
    //
});

// Multiple
Route::group(['middleware' => ['role:super-admin|admin','permission:manage-users|manage-posts']], function () {
    //
});
```

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Total

12

Last Release

2865d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c9cc3c784200fadc9ddae40aee1c7636897afbcb26082122a1ede305e66465b?d=identicon)[gurindersingh](/maintainers/gurindersingh)

---

Top Contributors

[![gurindersingh](https://avatars.githubusercontent.com/u/6223752?v=4)](https://github.com/gurindersingh "gurindersingh (27 commits)")

---

Tags

laravelsecurityaclpermission

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gurinder-laravel-acl/health.svg)

```
[![Health](https://phpackages.com/badges/gurinder-laravel-acl/health.svg)](https://phpackages.com/packages/gurinder-laravel-acl)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[wnikk/laravel-access-rules

Simple system of ACR (access control rules) for Laravel, with roles, groups, unlimited inheritance and possibility of multiplayer use.

103.6k1](/packages/wnikk-laravel-access-rules)

PHPackages © 2026

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