Showing posts from November, 2012

Install CakePHP 2.x in Ubuntu


HTTP Server. For example: Apache. mod_rewrite is preferred, but by no means required.PHP 5.2.8 or greater.Database Engine (MySQL (4 or greater), PostgreSQL, Microsoft SQL Server, SQLite) Download CakePHP 2.x at their website:

Extract your downloaded file.

Copy and paste the contents of the Cake archive in /var/www/cakephp

Make it writable, open your terminal and type:

    sudo chmod 777 -R /var/www/cakephp

Create your database.

Goto /var/www/cakephp/app/Config/ and rename your database.php.default to database.php.

Open database.php, then just replace the values in the $default array with those that apply to your setup. . A sample completed configuration array might look something like the following:


ACL 2.2.0 Plugin for CakePHP 2.2.3

This plugin is such an interface allowing to manage permissions of your application's users and roles.

1. Download latest CakePHP latest stable in

2. Install CakePHP see how: Install CakePHP 2.x in Ubuntu.

3. Setup a Simple Acl Controlled Application follow instruction here : Simple  Acl Controlled Application , part 1 only.

4. Download ACL Plugin for CakePHP 2.2

ACL Plugin Installation

copy the folder acl in your folder /app/pluginsconfigure the admin route (see the parameters found in Acl/Config/bootstrap.php in your file /app/Config/bootstrap.php or load the plugin with its own bootstrap.php file CakePlugin::load('Acl', array('bootstrap' => true)); see more: ACL Plugin Installation

 5. In your bootstrap.php located in your cakefolder/app/Plugin/Acl/Config/bootsrap.php. If you use groups (if you use database in in simple acl controlled application)  change 'Role&#…

CakePHP: GET Current Controller, Action and Parameters

We will have the following url:


To get the current controller:

echo $this->params['controller'];

To get the current action:

echo $this->action;

To get the first parameter:

echo $this->params['pass'][0];

To get the second parameter:

echo $this->params['pass'][1];

To get the first parameter:

echo $this->params['pass'][2];

and so on...

CakePHP : Accessing the logged in user

Once a user is logged in, you will often need some particular information about the current user. You can access the currently logged in user using AuthComponent::user(). This method is static, and can be used globally after the AuthComponent has been loaded. You can access it both as an instance method or as a static method:

You can access all the user's information(fields) from the users table except the password.

<?php // Use anywhere  // Accesing user’s id AuthComponent::user('id');                                                                
// Accesing user’s username AuthComponent::user('username');