PHPackages                             metrixinfo/laravel-permissions - 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. metrixinfo/laravel-permissions

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

metrixinfo/laravel-permissions
==============================

Fine grain user, group and role permissions

v0.2.1(4y ago)113GPL-2.0-or-laterPHPPHP ^7.4|^8.0

Since Jun 22Pushed 4y ago1 watchersCompare

[ Source](https://github.com/metrixinfo/laravel-permissions)[ Packagist](https://packagist.org/packages/metrixinfo/laravel-permissions)[ Docs](https://github.com/metrixinfo/laravel-permissions)[ RSS](/packages/metrixinfo-laravel-permissions/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

Fine Grain User and Role Permissions for Laravel
================================================

[](#fine-grain-user-and-role-permissions-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0e717b11dbdf99478fbd85a733d66a2291cc66485d5e40ece9f5b3a114756c38/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6574726978696e666f2f6c61726176656c2d7065726d697373696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/metrixinfo/laravel-permissions)[![Total Downloads](https://camo.githubusercontent.com/9972e3e0e770b6eb9cd8b7cea5dc1f0d15f4511cb2f1ac5dda17e998a678de49/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6574726978696e666f2f6c61726176656c2d7065726d697373696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/metrixinfo/laravel-permissions)

**Laravel Permissions** allows you to create fine grain permissions and assign them to users and roles.

You may assign zero or many roles to a user, and they will inherit the permissions assigned to those roles. You may also assign specific permissions to a specific user.

A user's permissions are cached for increased performance.

Requirements
------------

[](#requirements)

- PHP 7.4|8.0
- Laravel 7.x|8.x

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

[](#installation)

You can install the package via composer:

```
composer require metrixinfo/laravel-permissions
```

Publish the configuration by running the following artisan command:

```
php artisan vendor:publish --provider="Metrix\LaravelPermissions\LaravelPermissionsServiceProvider" --tag="permissions"
```

Run the migrations to create the required tables.

```
php artisan migrate
```

The migrations will create the following tables:

- permissions
- roles
- role\_user
- permission\_user
- permission\_role

Foreign Key constraints are enforced to guarantee data integrity. If you will be refreshing your database in your local environment you will need to disable them in the `down()` method of your `users` table migration.

*database/migrations/02014\_10\_12\_000000\_create\_users\_table.php*

```
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down(): void
 {
     Schema::disableForeignKeyConstraints();
     Schema::dropIfExists('users');
     Schema::enableForeignKeyConstraints();
 }
```

Usage
-----

[](#usage)

Include the following two traits in your User Model.

```
use \Metrix\LaravelPermissions\Traits\HasPermissions;
use \Metrix\LaravelPermissions\Traits\HasRoles;
```

### Permissions

[](#permissions)

A permission is described by an 'area' defined by you. Examples of areas could be 'blog.post' and 'blog.comment'. It is up to you to create the permissions your app requires by inserting them into the permissions table.

Each assigned permission can have a combination of these 4 actions:

- Read
- Write
- Edit
- Delete

You can check for permissions in any area of your code that you like. Some preferred locations would be within a Policy or a Gate method.

For a policy it could look something like this to allow the author and someone with a role of "Moderator" to edit a post:

```
/**
 * Determine whether the user can edit a post.
 *
 * @param  \App\Models\User  $user
 * @param  \App\Models\Post  $post
 *
 * @return bool
 */
public function update(User $user, Post $post):bool
{
    return $user->id === $post->user_id || Acl::hasEdit('posts');
}
```

Or it can be used to protect private areas of your site such as to only allow specific users to see the Horizon dashboard.

```
/**
 * Register the Horizon gate.
 *
 * This gate determines who can access Horizon in non-local environments.
 *
 * @return void
 */
protected function gate()
{
    Gate::define('viewHorizon', function ($user) {
        return Acl::hasRead('horizon');
    });
}
```

Console Commands
----------------

[](#console-commands)

Console commands are provided to help manage your permissions.

You can flush all the cached permissions:

```
php artisan acl:clear
```

or only the permissions belonging to a specific user.

```
php artisan acl:clear -u 212
```

You may manage permissions using the acl:permissions artisan command.

```
php artisan acl:permissions
```

You may manage roles using the acl:roles artisan command.

```
php artisan acl:roles
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please use the issue tracker.

Credits
-------

[](#credits)

- [Michael Love](https://github.com/metrixinfo)
- [All Contributors](../../contributors)

This package is inspired by the work done by Harro Verton (WanWizard) for [FuelPHP's](https://fuelphp.com/docs/packages/auth/ormauth/intro.html) OrmAuth package.

License
-------

[](#license)

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

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

1786d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5a25316a87583541e845e7320f45bbea2d07faf7f4d77e3a3ce75f090b3a05f2?d=identicon)[metrixinfo](/maintainers/metrixinfo)

---

Top Contributors

[![metrixinfo](https://avatars.githubusercontent.com/u/43896192?v=4)](https://github.com/metrixinfo "metrixinfo (26 commits)")

---

Tags

acllaravelpermissionslaravel-permissionsmetrixinfo

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[jeremykenedy/laravel-roles

A Powerful package for handling roles and permissions in Laravel. Supports Laravel 5.3 up to 12.

1.0k826.8k7](/packages/jeremykenedy-laravel-roles)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[hosseinhezami/laravel-permission-manager

Advanced permission manager for Laravel.

403.3k](/packages/hosseinhezami-laravel-permission-manager)[laravel-enso/permissions

Permissions dependency for Laravel Enso

1242.6k32](/packages/laravel-enso-permissions)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)[pschocke/laravel-telegram-login-widget

Easily integrate Telegrams login widget into your Laravel application to send Telegram messages

1610.4k](/packages/pschocke-laravel-telegram-login-widget)

PHPackages © 2026

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