PHP code example of locomotivemtl / charcoal-user
1. Go to this page and download the library: Download locomotivemtl/charcoal-user 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/ */
locomotivemtl / charcoal-user example snippets
use Laminas\Permissions\Acl\Acl;
use Laminas\Permissions\Acl\Resource\GenericResource as AclResource;
// Dependencies from `charcoal-user`
use Charcoal\User\Acl\Manager as AclManager;
$acl = new Acl();
// Add resource for ACL
$acl->addResource(new AclResource($resourceName));
$aclManager = new AclManager([
'logger' => $logger,
]);
$aclManager->loadPermissions($acl, $config['acl.permissions'], $resourceName);
$authorizer = new Authorizer([
'logger' => $logger,
'acl' => $acl,
'resource' => $resourceName,
]);
$isAllowed = $authorizer->userAllowed($user, [ 'permssion' ]);