PHPackages                             guava/simple-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. guava/simple-permissions

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

guava/simple-permissions
========================

Simple permission and role system for Laravel. Supports enums.

1.1.1(1y ago)235MITPHPPHP ^8.2

Since Apr 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/GuavaCZ/simple-permissions)[ Packagist](https://packagist.org/packages/guava/simple-permissions)[ Docs](https://github.com/guavaCZ/simple-permissions)[ GitHub Sponsors](https://github.com/GuavaCZ)[ RSS](/packages/guava-simple-permissions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (15)Versions (5)Used By (0)

[![simple-permissions Banner](docs/images/banner.jpg)](docs/images/banner.jpg)

Simple permission and role system for Laravel. Supports enums.
==============================================================

[](#simple-permission-and-role-system-for-laravel-supports-enums)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1e6bd777645f21267a3fe3cde04150707c34c0caa7822705f2e0a2b6ba818435/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67756176612f73696d706c652d7065726d697373696f6e732d666f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/guava/simple-permissions-for-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/38cbf7fba66d94805c624980628e14f6abc59e111ca6a4e54e2de30d8b3b7781/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f67756176612f73696d706c652d7065726d697373696f6e732d666f722d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/guava/simple-permissions-for-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/5eceb6e1961432048256a1295c96b83a4e7fa25a6366e04262d3dd2bf1a58a81/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f67756176612f73696d706c652d7065726d697373696f6e732d666f722d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/guava/simple-permissions-for-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/354f1d9f8924dc5b8c90e436a5247df3ab098e650218340fede941ccf4e0bbfd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67756176612f73696d706c652d7065726d697373696f6e732d666f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/guava/simple-permissions-for-laravel)

This is an opinionated simple permissions &amp; roles system for Laravel. It allows you to define roles and permissions as PHP classes and enums directly in your codebase. This allows for out of the box auto-completion support and superb developer experience.

Showcase
--------

[](#showcase)

This is where your screenshots and videos should go. Remember to add them, so people see what your plugin does.

Support us
----------

[](#support-us)

Your support is key to the continual advancement of our plugin. We appreciate every user who has contributed to our journey so far.

While our plugin is available for all to use, if you are utilizing it for commercial purposes and believe it adds significant value to your business, we kindly ask you to consider supporting us through GitHub Sponsors. This sponsorship will assist us in continuous development and maintenance to keep our plugin robust and up-to-date. Any amount you contribute will greatly help towards reaching our goals. Join us in making this plugin even better and driving further innovation.

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

[](#installation)

You can install the package via composer:

```
composer require guava/simple-permissions
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="simple-permissions-migrations"
```

You have to reneme the migration: `0000_00_00_000000_create_permissions_table.php`!

```
php artisan migrate
```

You can publish the config file with:

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

This is the contents of the published config file:

```
return [
    'tables' => [
        'roles' => 'model_has_role',
        'permissions' => 'model_has_permission',
    ],
];
```

Usage
-----

[](#usage)

### Model setup

[](#model-setup)

You need to add the `HasAccessControl` trait to your models that you want to add roles and permissions to.

This will add all necesary relationships and methods to start using access control.

```
use Guava\SimplePermissions\Concerns\HasAccessControl;

public class User extends Model
{
    use HasAccessControl;

    // ...
}
```

### Creating permissions

[](#creating-permissions)

Permissions can be created using an artisan command. Let's say you have a model `Post` and want to create permissions for handling access to the Post resource.

Simply run:

```
php artisan make:permission PostPermissions
```

This will create a new enum in `App\Auth\Permissions\PostPermissions` with some predefined CRUD permissions:

```
public enum PostPermissions: string implements \Guava\SimplePermissions\Contracts\Permission
{
    case VIEW = 'view';
    // ...Other redefined permissions
}
```

### Creating Roles

[](#creating-roles)

Roles can be created using an artisan command.

Simply run:

```
php artisan make:role SuperAdmin
```

This will create a new role in `App\Auth\Roles\SuperAdmin`:

```
public class SuperAdmin implements \Guava\SimplePermissions\Contracts\Role
{

    public function permissions() : array
    {
        return [
            // Add permissions here
            // Either one by one, such as:
            PostPermissions::VIEW,

            // or all at once:
           ...PostPermissions::cases()
        ];
    }
}
```

### Checking if a user has a permission

[](#checking-if-a-user-has-a-permission)

You can use Laravel's built-in methods to check permissions:

For example if a user has permissions to view a post, you could do:

```
$user->can(PostPermissions::VIEW)
```

### FilamentPHP integration

[](#filamentphp-integration)

All you need to do in order to add access control to your filament resources is to implement the `HasAuthorization` trait in your resource and define the Permission enum.

```
use Guava\SimplePermissions\Concerns\HasAuthorization;
use App\Auth\Permissions\PostPermissions;

public class PostResource extends Resource
{
    use HasAuthorization;

    protected static string $permissions = PostPermissions::class;

    // ...
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Lukas Frey](https://github.com/GuavaCZ)
- [All Contributors](../../contributors)
- Spatie - Our package simple-permissions-for-laravel is a modified version of [Spatie's Package SimplePermissions](https://github.com/spatie/package-simple-permissions-for-laravel-laravel)

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.4% 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 ~20 days

Total

4

Last Release

699d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/42d872f5f47cd71cfd46c8fbd6ec77a6bfb46d6d9499b5e1f843eb407c07f737?d=identicon)[Skrypt](/maintainers/Skrypt)

---

Top Contributors

[![lukas-frey](https://avatars.githubusercontent.com/u/10926334?v=4)](https://github.com/lukas-frey "lukas-frey (13 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")[![Uolsen](https://avatars.githubusercontent.com/u/47712422?v=4)](https://github.com/Uolsen "Uolsen (2 commits)")

---

Tags

laravelGuavasimple-permissions

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/guava-simple-permissions/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

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

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.7M41](/packages/jeffgreco13-filament-breezy)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)

PHPackages © 2026

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