PHPackages                             lcloss/simple-permission - 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. lcloss/simple-permission

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

lcloss/simple-permission
========================

Authorizations schema for Laravel projects

0.0.5(2y ago)015MITCSS

Since Sep 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/lcloss/simple-permission)[ Packagist](https://packagist.org/packages/lcloss/simple-permission)[ RSS](/packages/lcloss-simple-permission/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

SimplePermission
================

[](#simplepermission)

SimplePermission is a simple authorization package for Laravel. It is designed with Laravel 10, but may work with other versions. With this package, Roles and Permissions are added to your Laravel application, so you can easily manage authorization.

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

[](#installation)

1. Install the package via composer:

    ```
    composer require lcloss/simple-permission
    ```
2. Publish the config file:

    ```
    php artisan vendor:publish --provider="Lcloss\SimplePermission\SimplePermissionServiceProvider"
    ```
3. Compile assets:

    ```
    npm run build
    ```
4. Run the migrations:

    ```
    php artisan migrate
    ```
5. Add the `HasRoles` trait to your `User` model:

    ```
    use Lcloss\SimplePermission\Models\Traits\HasRoles;

    class User extends Authenticatable
    {
        use HasRoles;
    }
    ```
6. Add the `AuthGates` middleware to your `app\Http\Kernel.php` file:

    ```
    protected $middlewareGroups = [
        'web' => [
            // ...
            \Lcloss\SimplePermission\Http\Middleware\AuthGates::class,
        ],

        'api' => [
            // ...
            \Lcloss\SimplePermission\Http\Middleware\AuthGates::class,
        ],
    ];
    ```
7. Add the `role` to the `user`If you are using Laravel Fortify, you can chane App\\Actions\\Fortify\\CreateNewUser.php file:

    ```
    use Lcloss\SimplePermission\Models\Role;

    class CreateNewUser
    {
        // ...
        public function create(array $input)
        {
            // ...
            // If you are getting the first and last names:
            $name = trim($input['first_name'] . ' ' . $input['last_name']);

            DB::beginTransaction();

            $user = User::create([
                'name'      => $name,
                'email'     => $input['email'],
                'password'  => Hash::make($input['password']),
            ]);

            $countUsers = User::count();

            if ( $countUsers == 1 ) {
                $role = Role::where('slug', 'sysadmin')->first();
            } else {
                $role = Role::where('slug', 'user')->first();
            }
            $user->roles()->attach($role);

            DB::commit();

            return $user;
        }
    }
    ```

    With the configuration above, the first user created will be a `sysadmin`, and the others will be `user`.
8. Other considerations

Check package blade files. You can use your own blade files by replacing the blade file names in `config/simple-permission.php` file. Do not forget to:

a) Add @liwewireStyles() and @livewireScripts() to your layout file. b) Add @yield('scripts') to your layout file. c) Add @yield('modals') to the end of body, on the layout file.

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

[](#configuration)

You can change this package's configuration by editing the `config/simple-permission.php` file.

Database Seeder
---------------

[](#database-seeder)

This package comes with a database seeder that creates the default roles and permissions. You can run it with the following command:

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

Or, you can run individual seeders:

```
php artisan db:seed --class=SimplePermissionRoleSeeder
php artisan db:seed --class=SimplePermissionPermissionSeeder
```

Roles and Permissions
---------------------

[](#roles-and-permissions)

### Roles

[](#roles)

This package cames with default roles: 'sysadmin', 'admin', 'premium-user', 'user' and 'free-user'.

Each role has a single identification `slug` and a `level` to determine the role's hierarchy. Roles with `level` 1 are the highest level roles, and roles with `level` 300 are the lowest level roles. All roles with `level` 1 get access to all permissions.

You can customize the roles by editing the `database\seeders\SimplePermissionRoleSeeder.php` file.

### Permissions

[](#permissions)

Permissions follows the structure of `access`, `list` and CRUD operations (`create`, `read`, `update` and `delete`). Tipically `access` permisison is used to allow access to a resource, `list` permission is used to allow listing the resource, and CRUD permissions are used to allow operations on the resource.

A permission is composed by an `object` and an `action`, delimited by a `_` character. An object is a resource, like `users`, `roles`, `permissions`, `posts` or `comments`. An action is an operation on the resource, like `access`, `list`, `create`, `read`, `update` or `delete`.

So, the permission `users_create` determine if the user can create users, and the permission `users_list` determine if the user can list users.

You can customize the permissions by editing the `database\seeders\SimplePermissionPermissionSeeder.php` file.

To protect a route, you can use the `can` middleware:

```
Route::get('/users', [UserController::class, 'index'])->middleware('can:users_list');
```

To protect a controller method, you can use the `can` middleware:

```
use Gate;

class UserController extends Controller
{
    public function index()
    {
        Gate::authorize('users_list');

        // ...
    }
}
```

To protect a part of a view, you can use the `@can` directive:

```
@can('users_list')
    Users
@endcan
```

TODOs
-----

[](#todos)

- Add tests
- Add artisan commands

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

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

Total

5

Last Release

946d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e3338044b423a7d652c1788cb6a2247ac01877258d3c16362ac2645ff4de4707?d=identicon)[lcloss](/maintainers/lcloss)

---

Top Contributors

[![lcloss](https://avatars.githubusercontent.com/u/10761341?v=4)](https://github.com/lcloss "lcloss (6 commits)")

### Embed Badge

![Health badge](/badges/lcloss-simple-permission/health.svg)

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

###  Alternatives

[devdojo/auth

The auth package to make authentication in your laravel applications easy to use.

61979.4k2](/packages/devdojo-auth)[leanadmin/livewire-access

Control frontend access to properties/methods in Livewire using PHP 8 attributes.

9335.5k](/packages/leanadmin-livewire-access)[eightcedars/filament-inactivity-guard

Gracefully auto-logout users from idle/inactive Filament sessions

2238.1k2](/packages/eightcedars-filament-inactivity-guard)[dutchcodingcompany/livewire-recaptcha

Add Google Recaptcha V3 support to your Laravel Livewire components

2427.4k1](/packages/dutchcodingcompany-livewire-recaptcha)[headerx/laravel-jetstream-passport

Passport and OAuth2 support for laravel's jetstream starter kit (Livewire)

3016.4k1](/packages/headerx-laravel-jetstream-passport)

PHPackages © 2026

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