phalcon Working with ACL Creating an ACL


You can create ACL by using Phalcon\Acl\Adapter\Memory class:

$acl = new Phalcon\Acl\Adapter\Memory();

By default phalcon allows action to resource which has not been defined, to change this you can use:


Roles can be added in two ways - using Phalcon\Acl\Role or just plain string:

$roleAdministrator = new Phalcon\Acl\Role('Administrator');

Resources can be added in two ways too, you can add actions as single action or as array:

$resourceCategories = new Phalcon\Acl\Resource('categories');
$acl->addResource($resourceCategories, 'create');
$acl->addResource('products', ['create', 'update']);