1. Go to this page and download the library: Download judikael971/php-basic-acl 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/ */
judikael971 / php-basic-acl example snippets
= new ACL();
//--
// Add roles
//--
$acl->addRole('admin');
$acl->addRole('editor');
$acl->addRole('guest');
//--
// Add resources
//--
$acl->addResource('Article', array('read', 'create', 'edit', 'delete', 'publish'));
$acl->addResource('Page', array('read', 'create', 'edit', 'delete', 'publish'));
//--
// Define acces control
//--
//-- Admin have all permissions
$acl->allow('admin', 'Article');
$acl->allow('admin', 'Page');
//-- Editor have all permissions
$acl->allow('editor', 'Article');
$acl->allow('editor', 'Page');
//-- Editor haven't permission to delete 'Article' et delete or publish 'Page'
$acl->deny('editor', 'Article', 'delete');
$acl->deny('editor', 'Page', array('delete', 'publish'));
//-- Guest have only 'read' permission
$acl->allow('guest', 'Article', 'read');
$acl->allow('guest', 'Page', 'read');
//--
// Test Acces
//--
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.