1. Go to this page and download the library: Download adjustit/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/ */
adjustit / php-abac example snippets
use PhpAbac\Abac;
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 = new Abac([
'policy_rule_configuration.yml'
]);
$abac->enforce('create-group', $user);
use PhpAbac\Abac;
$abac = new Abac([
'policy_rule_configuration.yml'
]);
$check = $abac->enforce('read-public-group', $user, $group);
use PhpAbac\Abac;
$abac = new Abac([
'policy_rule_configuration.yml'
]);
$check = $abac->enforce('remove-group', $user, $group);
$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
]);
use PhpAbac\Abac;
$abac = new Abac([
'alcoollaw.yml'
]);
$check = $abac->enforce('alcoollaw', $user);
use PhpAbac\Abac;
$abac = new Abac([
'user_def.yml',
'gunlaw.yml',
],[],'rest/conf/policy/');
$check = $abac->enforce('gunlaw', $user);
json
""adjustit/php-abac": "dev-master"
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.