1. Go to this page and download the library: Download craftcamp/php-abac library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
craftcamp / php-abac example snippets
use PhpAbac\AbacFactory;
class User{
protected $id;
protected $isBanned;
public function getId() {
return $this->id;
}
public function setIsBanned($isBanned) {
$this->isBanned = $isBanned;
return $this;
}
public function getIsBanned() {
return $this->isBanned;
}
}
$user = new User();
$user->setIsBanned(true);
$abac = AbacFactory::getAbac([
'policy_rule_configuration.yml'
]);
$abac->enforce('create-group', $user);
$check = $abac->enforce('edit-group', $user, $group, [
'cache_result' => true,
'cache_ttl' => 3600, // Time To Live in seconds
'cache_driver' => 'memory' // memory is the default driver, you can avoid this option
]);