1. Go to this page and download the library: Download tihloh/prefab-permissions 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/ */
tihloh / prefab-permissions example snippets
$permissions = new PermissionManager([
'definitions' => __DIR__ . '/config/permissions.php',
]);
$permissions = new PermissionManager([
'definitions' => __DIR__ . '/config/permissions.json',
]);
class User implements PermissionSubjectInterface
{
public function __construct(
public int $id,
public array $groupIds = [],
) {}
public function permissionSubjectId(): int|string
{
return $this->id;
}
public function permissionGroupIds(): array
{
return $this->groupIds;
}
}
$permissions->can($user, 'documents.approve');
$permissions = new PermissionManager(
definitions: $definitions,
store: $customStore,
);
$permissions = new PermissionManager(
$definitions,
new PdoPermissionStore($pdo),
);