Developing with CakePHP: Creating a simple admin control panel

If you are like me, you prefer to have a specific url mapped to your applications control panel/backend etc.
This is usually something along the lines of or

Normally during the CakePHP “bake” process, the system will ask you what you want your admin route to be (default “admin”). Once this has been set you are merely 3 simple steps away from creating your own simple user control panel….

Step 1) Routing the admin url.
Add the following to your app/config/routes.php

Router::connect(‘/admin/’, array(‘controller’ => ‘admin’, ‘action’ => ‘index’));

This will route to the admin controller index function

Step 2) Creating the admin controller
Create the admin_controller.php file in /app/controllers/ and add the following code

class AdminController extends AppController
var $name = ‘Admin’;
var $uses = array(); //This controller does not need to use a model

function index(){


Step 3) Create your views
Create the app/views/admin/ directory and add an index.ctp view to it, with whaterver code you prefer (mine is merely a bunch of links to other controllers at this stage)

  • link(‘Posts’, ‘posts/’);
  • link(‘Comments’, ‘comments/’);