onix-systems-php / hyperf-policy
Policy library for hyperf
Installs: 2 454
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/onix-systems-php/hyperf-policy
Requires
- php: >=8.1
 - hyperf/constants: ^3.1
 - hyperf/di: ^3.1
 - hyperf/server: ^3.1
 - hyperf/testing: ^3.1
 - onix-systems-php/hyperf-core: >=1.2.0
 
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
 - mockery/mockery: ^1.0
 - phpstan/phpstan: ^1.0
 - phpunit/phpunit: >=7.0
 - swoole/ide-helper: ^4.5|^5.0
 
Suggests
- swow/swow: Required to create swow components.
 
README
Uses Symfony-like voters to check permissions
Install:
composer require onix-systems-php/hyperf-policy
To make it works, you need:
- 
create policy class based on
OnixSystemsPHP\HyperfPolicy\Policy\AbstractPolicy - 
add
OnixSystemsPHP\HyperfPolicy\Annotation\Policyannotation to the policy and setup it's priority (higher number executes first) - 
specify what classes\objects and actions your policy will work with
 - 
specify vote logic and return one of the values:
PolicyVote::ACCESS_DENIED- stop execution and throw exception specified ingetExceptionmethodPolicyVote::ACCESS_GRANTED- allow current action and skip all following policiesPolicyVote::ACCESS_ABSTAIN- go to next policy, allow action if no policies left to check
 - 
create data specifier class based on
OnixSystemsPHP\HyperfPolicy\Policy\AbstractDataSpecifier - 
add
OnixSystemsPHP\HyperfPolicy\Annotation\DataSpecifierannotation to the specifier and setup it's priority (higher number executes first) - 
specify what repositories and actions your specifier will work with