PHP Classes


Recommend this page to a friend!
  Classes of Rogério Taques  >  CodeIgniter ACL User Management  >  >  Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: CodeIgniter ACL User Management
Manage the access of CodeIgniter users using ACL
Author: By
Last change:
Date: 5 years ago
Size: 2,135 bytes


Class file image Download

CI ACL 1.0 beta

Implements an Access Control List for your applications written with Codeigniter.

You should use it in order to help you control which path the user can (or cannot) access.

Getting Started

Download this project, and copy its content into your Codeigniter app, under `application` folder.

For example:

   / (project root directory)
   -- ...

After "instal" it on your app, then you'll need to setup all acl definitions.

All those definitions should be placed in ` ./applicaton/config/acl.php`, i.e:

$acl = array(


	'welcome/index' => array(

	'welcome/private_users' => array(
		'user'  => TRUE,
        'admin' => FALSE

	'welcome/private_admins' => array(
		'user'  => FALSE,
        'admin' => TRUE


Finally, in order to test if given path is valid or not, do as following:

    $ci =& get_instance();
    // check if given path isn't public
    if (! $ci->acl->is_public('path/to/test'))
        if (! $ci->acl->is_allowed('path/to/test', 'role-to-test'))
            // do your stuff here ...
            // i.e: set the error message and redirect to some page.

That's all.


There some methods that can be used on runtime:

is_public( path : string ) : boolean

Return TRUE when given path is set as 'public', otherwise, return FALSE.

is_allowed( path: string, role : string ) : boolean

Return TRUE when given role is set as 'true' for given path, otherwise, return FALSE.

set( path : string, config : array ) : void

This method is used to add new ACL rules that are not present on `config/acl` on runtime.

It's very useful when you're storing your ACL rules on database.


   $ci->acl->set( 'a/new/path/to/check', array( 'user' => FALSE, 'admin' => TRUE ) ); // or
   $ci->acl->set( 'a/new/path/to/check', array( 'public' ) );

Get involved

Report bugs, make suggestions and get involved on contributions.

Feel free to get in touch. ;)

For more information send a message to info at phpclasses dot org.