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

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

giatechindo/hypervel-permission
===============================

Permission handling for Hypervel framework with ID and UUID support

v1.0.0(12mo ago)213[2 issues](https://github.com/Giatechindo/hypervel-permission/issues)MITPHPPHP &gt;=8.2

Since May 11Pushed 12mo agoCompare

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

READMEChangelogDependencies (9)Versions (4)Used By (0)

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

[](#hypervel-permission)

[![Latest Version](https://camo.githubusercontent.com/4b88b613be71d159285b1ca37a9efb422d101021b53caf30c01f30025ad9a8e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67696174656368696e646f2f687970657276656c2d7065726d697373696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/giatechindo/hypervel-permission)[![Total Downloads](https://camo.githubusercontent.com/d8315eb9a9cd31010a7ac87c65176faf4be80a5678ca10152ef0edc0b7e42b12/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67696174656368696e646f2f687970657276656c2d7065726d697373696f6e2e7376673f7374796c652d666c61742d737175617265)](https://packagist.org/packages/giatechindo/hypervel-permission)[![License](https://camo.githubusercontent.com/cd2dc1d98fd39e8fd68eeaf3a4d1343e4b317a8f06528e9f79f915369f57ad2f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f67696174656368696e646f2f687970657276656c2d7065726d697373696f6e2e7376673f7374796c652d666c61742d737175617265)](https://packagist.org/packages/giatechindo/hypervel-permission)

Role-based permission handling for Hypervel framework with ID and UUID support.

Structure
---------

[](#structure)

```
hypervel-permission/
├── composer.json
├── config/
│   └── permission.php
├── database/
│   └── migrations/
│       ├── 2025_05_12_000000_create_permission_tables.php
│       └── 2025_05_12_000001_add_uuid_support.php
├── src/
│   ├── Contracts/
│   │   ├── Permission.php
│   │   └── Role.php
│   ├── Exceptions/
│   │   ├── PermissionAlreadyExists.php
│   │   ├── PermissionDoesNotExist.php
│   │   ├── RoleAlreadyExists.php
│   │   └── RoleDoesNotExist.php
│   ├── Models/
│   │   ├── Permission.php
│   │   └── Role.php
│   ├── PermissionRegistrar.php
│   ├── PermissionServiceProvider.php
│   └── Traits/
│       ├── HasPermissions.php
│       └── HasRoles.php
├── tests/
│   ├── bootstrap.php
│   ├── PermissionTest.php
│   └── RoleTest.php
├── LICENSE
├── README.md
└── phpunit.xml.dist
```

Features
--------

[](#features)

- Role and permission management
- Support for both ID and UUID
- Morph relationships for flexible model associations
- Clean, maintainable code with comprehensive tests
- Inspired by Spatie's Laravel Permission

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

[](#installation)

1. Install the package via Composer:

```
composer require giatechindo/hypervel-permission
```

```
composer require giatechindo/hypervel-permission:1.0.0
```

2. Copy the configuration file to your project:

```
cp vendor/giatechindo/hypervel-permission/config/permission.php config/permission.php
```

3. Copy the migration files to your project's migration directory:

```
cp vendor/giatechindo/hypervel-permission/database/migrations/*.php database/migrations/
```

4. (Optional) If you want to use UUID instead of auto-incrementing IDs, add the following to your `.env` file:

```
PERMISSION_USE_UUID=true
```

5. Run the migrations to create the necessary tables:

```
php artisan migrate
```

If you want to start fresh, you can drop all tables and re-run migrations:

```
php artisan migrate:fresh
```

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

[](#configuration)

The configuration file `config/permission.php` allows you to customize the package behavior. Key options include:

- **`use_uuid`**: Set to `true` to use UUIDs instead of auto-incrementing IDs.
- **`models`**: Define custom model classes for `Role` and `Permission`.
- **`table_names`**: Customize the database table names used by the package.

Example configuration:

```
return [
    'use_uuid' => env('PERMISSION_USE_UUID', false),
    'models' => [
        'permission' => Giatechindo\HypervelPermission\Models\Permission::class,
        'role' => Giatechindo\HypervelPermission\Models\Role::class,
    ],
    'table_names' => [
        'permissions' => 'permissions',
        'roles' => 'roles',
        'model_has_permissions' => 'model_has_permissions',
        'model_has_roles' => 'model_has_roles',
        'role_has_permissions' => 'role_has_permissions',
    ],
];
```

Usage
-----

[](#usage)

### Adding the Traits

[](#adding-the-traits)

To enable role and permission management on your models (e.g., `User`), add the `HasRoles` and `HasPermissions` traits:

```
use Giatechindo\HypervelPermission\Traits\HasRoles;
use Giatechindo\HypervelPermission\Traits\HasPermissions;

class User extends Model
{
    use HasRoles, HasPermissions;
}
```

### Creating Roles and Permissions

[](#creating-roles-and-permissions)

You can create roles and permissions programmatically:

```
use Giatechindo\HypervelPermission\Models\Role;
use Giatechindo\HypervelPermission\Models\Permission;

// Create a role
$adminRole = Role::create(['name' => 'admin']);

// Create a permission
$editPostPermission = Permission::create(['name' => 'edit-post']);
```

### Assigning Roles and Permissions

[](#assigning-roles-and-permissions)

Assign roles or permissions to a user:

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

// Assign a role
$user->assignRole('admin');

// Assign a permission
$user->givePermissionTo('edit-post');
```

### Checking Roles and Permissions

[](#checking-roles-and-permissions)

Check if a user has a specific role or permission:

```
// Check if user has a role
if ($user->hasRole('admin')) {
    echo "User is an admin!";
}

// Check if user has a permission
if ($user->hasPermissionTo('edit-post')) {
    echo "User can edit posts!";
}
```

### Using Middleware

[](#using-middleware)

You can protect routes using the package's middleware to restrict access based on roles or permissions:

```
Route::group(['middleware' => ['role:admin']], function () {
    Route::get('/admin', [AdminController::class, 'index']);
});

Route::group(['middleware' => ['permission:edit-post']], function () {
    Route::get('/edit-post', [PostController::class, 'edit']);
});
```

### Morph Relationships

[](#morph-relationships)

The package supports morph relationships, allowing you to assign roles and permissions to any model, not just `User`. For example:

```
use Giatechindo\HypervelPermission\Models\Permission;

$team = Team::find(1);
$team->givePermissionTo('manage-team');
```

Testing
-------

[](#testing)

The package includes PHPUnit tests. To run the tests:

```
composer test
```

To generate a test coverage report:

```
composer test-coverage
```

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

[](#requirements)

- PHP &gt;= 8.2
- Hypervel Framework ^0.1
- Ramsey UUID ^4.7
- Symfony Filesystem ^7.2
- Hyperf Database ^3.1
- PHP Dotenv ^5.6

For development and testing:

- Hyperf Testing ~3.1.0
- PHPUnit ^10.5
- PHPUnit Code Coverage ^10.1
- Mockery ^1.6

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

Credits
-------

[](#credits)

This package is inspired by [Spatie Laravel Permission](https://github.com/spatie/laravel-permission) and adapted for the Hypervel framework by [Giatechindo](https://github.com/giatechindo).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

362d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/884e7a416fccafdfcba3606c5dfa6170135cb71bbb535db2892bf6230dae4923?d=identicon)[ugunNet21](/maintainers/ugunNet21)

---

Top Contributors

[![ugunNet21](https://avatars.githubusercontent.com/u/45864165?v=4)](https://github.com/ugunNet21 "ugunNet21 (19 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)[microsoft/kiota-authentication-phpleague

Authentication provider for Kiota using the PHP League OAuth 2.0 client to authenticate against the Microsoft Identity platform

153.2M7](/packages/microsoft-kiota-authentication-phpleague)[descope/descope-php

Descope SDK for PHP

3814.0k](/packages/descope-descope-php)

PHPackages © 2026

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