mibo / px
PHP Library for Permissions [RBAC]
Installs: 7 230
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- illuminate/support: ^12.0|^11.0|^10.0
Requires (Dev)
- nette/neon: ^3.3
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^2.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/php-invoker: ^5.0
- phpunit/phpunit: ^11.5
- slevomat/coding-standard: ^8.14
- squizlabs/php_codesniffer: ^3.6
README
Permissions and their evaluating. Role Based System.
Implementation
composer require mibo/px
Requirements
- PHP ^8.0
- illuminate/support ^10.0-^12.0
Usage
// 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:
class MyUser implements \MiBo\PX\Contracts\HasPermissionsInterface { use \MiBo\PX\Contracts\HasPermissionsTrait; public function __construct() { $this->registerPermissions( [ "my.own.permission", "my.another.permission" ] ); } }