Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/4513/px
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/4513/px
- Owner: 4513
- License: mit
- Created: 2022-11-04T16:46:27.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-30T06:32:39.000Z (6 months ago)
- Last Synced: 2024-09-18T13:16:32.673Z (about 2 months ago)
- Language: PHP
- Size: 44.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PX
[![codecov](https://codecov.io/gh/4513/px/graph/badge.svg?token=GDYA37GMXC)](https://codecov.io/gh/4513/px)
Permissions and their evaluating. Role Based System.
## Implementation
```bash
composer require mibo/px
```### Requirements
* PHP ^8.0
* illuminate/support ^9.36## Usage
```php
// Load the user that has permissions.
/** @var \MiBo\PX\Contracts\HasPermissionsInterface $user */
$user;if ($user->hasPermission("my.own.permission")) {
// Do some action
} else {
// You may log that the user is missing required permission.
}
```When implementing the interface, consider to use provided trait. If doing so,
call `registerPermissions` method with all available permissions for the user:
```php
class MyUser implements \MiBo\PX\Contracts\HasPermissionsInterface
{
use \MiBo\PX\Contracts\HasPermissionsTrait;
public function __construct()
{
$this->registerPermissions(
[
"my.own.permission",
"my.another.permission"
]
);
}
}
```