PHPackages                             ykozhemiaka/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. [Database &amp; ORM](/categories/database)
4. /
5. ykozhemiaka/simple-permission

ActiveLibrary[Database &amp; ORM](/categories/database)

ykozhemiaka/simple-permission
=============================

Simple permission handling for PHP.

v1.0.0(6y ago)09[1 PRs](https://github.com/YaroslavKozhemiaka/simple-permission/pulls)MITPHP

Since Oct 21Pushed 5y ago1 watchersCompare

[ Source](https://github.com/YaroslavKozhemiaka/simple-permission)[ Packagist](https://packagist.org/packages/ykozhemiaka/simple-permission)[ RSS](/packages/ykozhemiaka-simple-permission/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

Simple permission
=================

[](#simple-permission)

Simple permission management for PHP.

Getting Started
---------------

[](#getting-started)

These instructions will get you quick start for simple permission management in your PHP project.

### Installation

[](#installation)

- Require this package in the `composer.json`
    `composer require ykozhemiaka/simple-permission`
- Before using all commands which provide this package you should init `Capsule` (for example in `index.php` where boots application)

```
use Illuminate\Database\Capsule\Manager as Capsule;

$capsule = new Capsule;

$capsule->addConnection([
            'driver' => 'mysql',
            'host' => 'localhost',
            'database' => 'simple_permissions',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8mb4'
        ]);

$capsule->setAsGlobal();

$capsule->bootEloquent();
```

- After required the package you should create all necessary tables.
    If you've already created `users` table you couldn't do next instruction, but if you haven't `users` table in your database you should execute next script to create the table.

```
use SimplePermission\Database\Schemas\UsersSchema;

$userSchema = new UsersSchema($capsule);
$userSchema->createTable();
```

- Next, you need to create several tables that are associated with permission tables.

```
use SimplePermission\Database\Schemas\PermissionSchemas;

$permissionSchemas = new PermissionSchemas($capsule);
$permissionSchemas->createTable();
```

- If table users name isn't `users` you should set custom name in `SimplePermission\Models\User.php`

```
namespace SimplePermission\Models;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use HasPermission;

    protected $table = 'custom-table-name';

...
```

### Quick start

[](#quick-start)

#### Management permissions

[](#management-permissions)

- Create new permission "Edit article".

```
use SimplePermission\Repositories\PermissionRepository;

$permissionRepo = new PermissionRepository();
$permission = $permissionRepo->create('Edit article');
```

- Update created permission above.

```
$id = 1;

$permission = $permissionRepo->update('Edit posts', 1)
```

- Delete permission by name

```
$permissionRepo->deleteByName('Edit article');
```

Or by id

```
$permissionRepo->deleteById(2)
```

- Assign role to permission

```
$role = Role::find(1);
//or you can use role id $role = 1;

$permission = $permissionRepo->whereId(1)->assignRole($role);
```

- Revoke permission to role

```
$permissionRepo->whereId(1)->terminateToRole($role);
```

#### Management permissions via user

[](#management-permissions-via-user)

- Give permission to user.

```
$user = User::find(1);

$role = Role::find(1);
//or you can use role id $role = 1;
$permission = Permission::find(1);
//or you can use permission id $permission = 1;

$user->allowTo($permission);
```

- Assign role to user.

```
$user->grantRole($role);
```

- Verify permission.

```
$user->ableTo('Edit posts');
```

- Verify role.

```
$user->hasRole('Admin');
```

- Revoke permission.

```
$user->terminateToPermission($permission);
```

- Revoke role.

```
$user->terminateToRole($role);
```

#### Management roles

[](#management-roles)

- Create role.

```
$roleRepo = new RoleRepository();
$role = $roleRepo->create('Admin');
```

- Fetch all permissions attached to role.

```
$role->permissions;
```

- Update role.

```
$role = $roleRepo->update('Moderator', $role->id);
```

- Delete by name

```
$roleRepo->deleteByName($role->name);
```

Or delete by id

```
$roleRepo->deleteById($role->id);
```

- Attach permission to role.

```
$role = $roleRepo->whereId(1)->grant($permission)
```

- Assign role to user.

```
$role = $roleRepo->whereId(1)->assignRoleTo($user)
```

- Revoke role to user.

```
$roleTerminate = $roleRepo->whereId(1)->terminateToUser($user);
```

- Revoke permission to user.

```
$role = $roleRepo->whereId(1)->terminateToPermission($permission);
```

Built With
----------

[](#built-with)

- [illuminate/database](https://packagist.org/packages/illuminate/database) - The Illuminate Database component is a full database toolkit for PHP.

Authors
-------

[](#authors)

- **Yaroslav Kozhemiaka** - *Initial work* - [Yaroslav Kozhemiaka](https://github.com/YaroslavKozhemiaka)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

2395d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/50923583?v=4)[Yaroslav Kozhemiaka](/maintainers/YaroslavKozhemiaka)[@YaroslavKozhemiaka](https://github.com/YaroslavKozhemiaka)

---

Top Contributors

[![YaroslavKozhemiaka](https://avatars.githubusercontent.com/u/50923583?v=4)](https://github.com/YaroslavKozhemiaka "YaroslavKozhemiaka (8 commits)")

---

Tags

acleloquentpermission-managerpermissionsphproleroles-managementsecuritysecurityaclpermissionrolesimple permission

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

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

Eloquent roles and abilities.

3.6k4.4M25](/packages/silber-bouncer)[mostafamaklad/laravel-permission-mongodb

Permission handling for Laravel 5.2 and up using mongodb

113220.0k2](/packages/mostafamaklad-laravel-permission-mongodb)[efficiently/authority-controller

AuthorityController is an PHP authorization library for Laravel 5 which restricts what resources a given user is allowed to access.

15533.2k](/packages/efficiently-authority-controller)[konekt/acl

Concord Module for Permission handling (Laravel 10 - 12)

1070.8k1](/packages/konekt-acl)[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)
