Introduction To CakePHP


 Cake PHP

CakePHP is a framework used for PHP to develop applications conveniently and rapidly. It is free and open source development framework. Well most of us have doubt on what a framework is. In simple words we can say that it is a platform with additional libraries for a programming language to develop applications in a particular fashion.


Now the heart of CakePHP is the MVC system or the Model View and Controller which separates it from the core PHP programming style. We can understand the structure with the help of a diagram.  The Controller is which performs all the logic, Model provides many inbuilt functions and you can create your own functions in Model, Model performs all interactivity with database and Views provide a GUI to the user to interact with.


Download the cakephp  setup from and paste it in your xampp folder in C: directory and unpack the contents and you will see a folder named after the version say cakephp- 2.3.6, if you wish you can change the name of the folder but it is better not to change . Go to your web browser and open localhost/< name of cake php folder>  like this


and you will see a screen like this:



And now get ready to configure Cake with your system and quickly make few changes:

1.Configure your database with cakephp
Open phpMyAdmin through xampp and create a database say ‘proj’. Now to configure this database with cakephp, go to app/Config/database.php.default, make a copy of this file in the same directory and name it as database.php

And now open this database.php file and u can see an array named ‘default’, make changes to it according to your system. Change ‘login’ = ‘root’, ‘password’ = ‘’, ’database’=’<name of any database you want to configure with cake, there can be multiple entries too>’ say ‘database’ = ‘proj’,’student’ and finally the file should look like

After saving the changes go and refresh the cakephp welcome page and now the red coloured rows have turned to green indicating that a particular database is now configured

2. Go to the app/config/core.php file line 187 and change the value for the security salt, change the string to any random string

Configure:: write(‘Security.salt’, ‘xhghghjgfghfhgjgj’);

For now just know that security salt is used for hashing purpose.

3. In the same file (app/config/core.php) go to line 192 and change the value of security cipherseed to a string of any random numbers (only numbers no alphabet or any other symbol)


Now the refresh the page on your webbrowser and it should look like this.



With these changes you are all set to start your first application. To start just memorize the following naming conventions used in cakephp, without these you are bound to get hell lot of errors.

 Naming conventions

CakePHP has its own set of Naming Conventions which are necessary to follow. Controller- the name of the controller is always in plural, Model– always in singular, and for views go to the View folder and create a folder of the same name as the controller and inside that create CTP files with the same name as methods created in the controller and in database always create tables with the same name as the controller that is plural names.It will be well understood by a sample application

How to include .ctp extension in your Notepad++ editor?

It is always better to use notepad++ to write your code. If you don’t have it then download it from internet. But notepad++ do not come inbuilt configuration with .ctp extension files like it is for .html, .php, .java files. So for that you have to manually do that. Go to

settings-> Style configurator-> Language-> PHP

and add ‘ctp’ in user extension box below and save and exit. It should work. And if need be run the notepad++ in administrator mode and then make the changes. Now restart your notepad and check it takes the.ctp extension well or not by writing a sample html/php code and saving it with .ctp extension.



1 Comment

Leave A Reply