Download the PHP package giatechindo/hypervel-permission without Composer
On this page you can find all versions of the php package giatechindo/hypervel-permission. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download giatechindo/hypervel-permission
More information about giatechindo/hypervel-permission
Files in giatechindo/hypervel-permission
Package hypervel-permission
Short Description Permission handling for Hypervel framework with ID and UUID support
License MIT
Informations about the package hypervel-permission
Hypervel Permission
Role-based permission handling for Hypervel framework with ID and UUID support.
Structure
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
-
Install the package via Composer:
-
Copy the configuration file to your project:
-
Copy the migration files to your project's migration directory:
-
(Optional) If you want to use UUID instead of auto-incrementing IDs, add the following to your
.env
file: - Run the migrations to create the necessary tables:
If you want to start fresh, you can drop all tables and re-run migrations:
Configuration
The configuration file config/permission.php
allows you to customize the package behavior. Key options include:
use_uuid
: Set totrue
to use UUIDs instead of auto-incrementing IDs.models
: Define custom model classes forRole
andPermission
.table_names
: Customize the database table names used by the package.
Example configuration:
Usage
Adding the Traits
To enable role and permission management on your models (e.g., User
), add the HasRoles
and HasPermissions
traits:
Creating Roles and Permissions
You can create roles and permissions programmatically:
Assigning Roles and Permissions
Assign roles or permissions to a user:
Checking Roles and Permissions
Check if a user has a specific role or permission:
Using Middleware
You can protect routes using the package's middleware to restrict access based on roles or permissions:
Morph Relationships
The package supports morph relationships, allowing you to assign roles and permissions to any model, not just User
. For example:
Testing
The package includes PHPUnit tests. To run the tests:
To generate a test coverage report:
Requirements
- PHP >= 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
This package is open-sourced software licensed under the MIT license.
Credits
This package is inspired by Spatie Laravel Permission and adapted for the Hypervel framework by Giatechindo.
All versions of hypervel-permission with dependencies
hypervel/framework Version ^0.1
ramsey/uuid Version ^4.7
symfony/filesystem Version ^7.2
hyperf/database Version ^3.1
vlucas/phpdotenv Version ^5.6