Welcome to the Cookbook

loading...

5.1.3.1 Getting Started

The default ACL permissions implementation is database powered. Cake's database ACL consists of a set of core models, and a console application that comes with your Cake installation. The models are used by Cake to interact with your database in order to store and retrieve nodes in tree format. The console application is used to initialize your database and interact with your ACO and ARO trees.

To get started, first you'll need to make sure your /app/config/database.php is present and correctly configured. See section 4.1 for more information on database configuration.

Once you've done that, use the CakePHP console to create your ACL database tables:

$ cake schema run create DbAcl

Running this command will drop and re-create the tables necessary to store ACO and ARO information in tree format. The output of the console application should look something like the following:

---------------------------------------------------------------
Cake Schema Shell
---------------------------------------------------------------

The following tables will be dropped.
acos
aros
aros_acos

Are you sure you want to drop the tables? (y/n) 
[n] > y
Dropping tables.
acos updated.
aros updated.
aros_acos updated.

The following tables will be created.
acos
aros
aros_acos

Are you sure you want to create the tables? (y/n) 
[y] > y
Creating tables.
acos updated.
aros updated.
aros_acos updated.
End create.

This replaces an older deprecated command, "initdb".

You can also use the SQL file found in app/config/sql/db_acl.sql, but that's nowhere near as fun.

When finished, you should have three new database tables in your system: acos, aros, and aros_acos (the join table to create permissions information between the two trees).

If you're curious about how Cake stores tree information in these tables, read up on modified database tree traversal. The ACL component uses CakePHP's Tree Behavior to manage the trees' inheritances. The model class files for ACL are all compiled in a single file db_acl.php.

Now that we're all set up, let's work on creating some ARO and ACO trees.