A simple user class for working with Laminas Permissions ACL. It extends the Laminas\Permissions\Acl\Role\RoleInterface.

0.4.4 2022-06-08 17:46 UTC

This package is auto-updated.

Last update: 2024-06-08 21:48:53 UTC


This package is simply a user object which extends the Zend\Permissions\Acl\Role\RoleInterface. This allows you to pass the user object to the isAllowed() method when querying the ACL. You can also populate it miscellaneous data from your Authentication library or from some other source.

See for details on using Zend's ACL library.


$acl = new Zend\Permissions\Acl\Acl;
$acl->addRole('user', 'guest');
$acl->addRole('admin', 'user');
$acl->allow('guest', 'posts', 'view');
$acl->allow('user', 'posts', 'add');

// User data, such as the role, username, etc. could come from an Auth object or some other object, such as a Config object. That is up to you. 

$user = new \Vespula\User\User('admin');
$user->setFullname('Joe User');

if ($acl->isAllowed($user, 'posts', 'add')) {
    // etc.

echo "Hello " . $user->getFullname();