PHPackages                             aef/hypervel-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. aef/hypervel-permission

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

aef/hypervel-permission
=======================

Role &amp; Permission management for Hypervel, with cache support

0.1.0(8mo ago)2381MITPHPPHP &gt;=8.0

Since Sep 8Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/ahmed-abdelnaby-fahmy/hypervel-permission)[ Packagist](https://packagist.org/packages/aef/hypervel-permission)[ RSS](/packages/aef-hypervel-permission/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Hypervel Permission
===================

[](#hypervel-permission)

Role &amp; Permission management for the **[Hypervel Framework](https://hypervel.dev)**, with first-class cache support.

> Effortlessly assign **roles** and **permissions** to your Hypervel users, speed-boosted by smart caching.

---

Table of Contents
-----------------

[](#table-of-contents)

1. [Features](#features)
2. [Installation](#installation)
3. [Configuration](#configuration)
4. [Basic Usage](#basic-usage)
5. [Advanced Usage](#advanced-usage)
6. [Testing](#testing)

---

Features
--------

[](#features)

- 🔑 **Create** roles &amp; permissions via models or artisan commands
- 🧑‍🤝‍🧑 **Assign** multiple roles to users (or vice versa)
- 🛂 **Authorize** via roles *or* direct permissions
- 🚀 **Cache** layer with configurable store, key &amp; TTL
- 🛡 **Multi-guard** support out of the box
- 🔍 Clean, expressive API (`hasRole()`, `hasPermissionTo()`, …)
- 🧪 Thoroughly tested &amp; production-ready

---

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

[](#installation)

```
composer require aef/hypervel-permission
```

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

[](#configuration)

Publish the config file and the migrations:

```
php artisan vendor:publish permission-config
php artisan vendor:publish permission-migrations
```

In the providers array, add the following line:

```
'providers' => [
    // Other service providers...

    Hypervel\Permission\PermissionServiceProvider::class,
],
```

Basic Usage
-----------

[](#basic-usage)

Creating permissions &amp; roles

```
use Hypervel\Permission\Models\Permission;
use Hypervel\Permission\Models\Role;

Permission::create(['name' => 'edit articles']);
Permission::create(['name' => 'delete articles']);

$writer = Role::create(['name' => 'writer']);
$writer->givePermissionTo('edit articles', 'delete articles');

$admin = Role::create(['name' => 'admin']);
$admin->givePermissionTo(Permission::all());
```

Assigning and Revoking Roles/Permissions
----------------------------------------

[](#assigning-and-revoking-rolespermissions)

```
$user = \App\Models\User::find(1);

$user->assignRole('writer', 'admin');
$user->syncRoles(['writer', 'admin']);

$user->removeRole('admin');

$user->givePermissionTo('publish articles');
$user->syncPermissions(['edit articles', 'delete articles']);

$user->revokePermissionTo('edit articles');  // Remove single permission
$user->revokePermissionTo('edit articles', 'delete articles');  // Remove multiple
```

Checking abilities
------------------

[](#checking-abilities)

```
$user->hasPermissionTo('edit articles');          // true/false
$user->hasRole('writer');                        // true/false
$user->hasAnyRole(['writer', 'moderator']);      // true/false
$user->hasAllPermissions(['edit', 'publish']);   // true/false
```

### Check if the current user has permission

[](#check-if-the-current-user-has-permission)

```
Gate::allows('edit articles')
```

Getting all permissions
-----------------------

[](#getting-all-permissions)

```
$user->getAllPermissions();      // direct + via roles
$user->getPermissionsViaRoles(); // only via roles
$user->permissions;              // only direct
```

Advanced Usage
--------------

[](#advanced-usage)

Caching is on by default and automatically flushed whenever a permission, role, or related pivot changes.

```
'cache' => [
'store'      => env('PERMISSION_CACHE_STORE', 'redis'),
'key'        => env('PERMISSION_CACHE_KEY', 'hypervel.permission.cache'),
'expiration' => env('PERMISSION_CACHE_TTL', 3600), // seconds
],
```

Multiple guards
---------------

[](#multiple-guards)

```
// creating
Permission::create(['name' => 'edit articles', 'guard_name' => 'api']);
Role::create(['name' => 'writer', 'guard_name' => 'api']);

// checking (guard auto-detected from current auth)
$user->hasPermissionTo('edit articles');        // defaults to current guard
$user->hasPermissionTo('edit articles', 'api'); // explicit
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance60

Regular maintenance activity

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity30

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

Unknown

Total

1

Last Release

252d ago

### Community

Maintainers

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

---

Top Contributors

[![ahmed-abdelnaby-fahmy](https://avatars.githubusercontent.com/u/40221156?v=4)](https://github.com/ahmed-abdelnaby-fahmy "ahmed-abdelnaby-fahmy (8 commits)")

### Embed Badge

![Health badge](/badges/aef-hypervel-permission/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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