https://github.com/perer876/guard
Lightweight, enum-based definition, querying and mapping of permissions in PHP applications.
https://github.com/perer876/guard
authorization permission rbac
Last synced: 5 months ago
JSON representation
Lightweight, enum-based definition, querying and mapping of permissions in PHP applications.
- Host: GitHub
- URL: https://github.com/perer876/guard
- Owner: Perer876
- License: mit
- Created: 2025-07-03T04:54:43.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-08-13T05:23:47.000Z (10 months ago)
- Last Synced: 2025-09-10T13:32:00.642Z (9 months ago)
- Topics: authorization, permission, rbac
- Language: PHP
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> [!IMPORTANT]
> Still in development, not feature complete.
# Guard
Lightweight, enum-based definition, querying and mapping of permissions in PHP applications.
## Usage
You can define roles and permissions using an enum.
For example, you can define roles like this:
```php
*/
#[Override]
public function getRoles(): iterable
{
yield $this->role;
}
/** @return array */
protected function casts(): array
{
return [
'role' => UserRole::class,
];
}
/* ... */
}
```
In a policy, for example, you can check the user model permissions like this:
```php
$user->hasPermission(TodoPermission::ViewAny);
```
## Installation
You can install the package via Composer:
```bash
composer require perer876/permission:v1.0.0-alpha.2
```
## Documentation
Coming soon.