What Is Cakephp?
CakePHP is a free, open-source, rapid development framework for PHP. It’s a foundational structure for programmers to create web applications. CakePHP goal is to enable developers to work in a structured and rapid manner–without loss of flexibility. CakePHP takes the monotony out of web development.
When CakePHP Was Developed?
CakePHP started in April 2005.When a Polish programmer Michal Tatarynowicz wrote a minimal version of a Rapid Application Framework in PHP, dubbing it Cake.CakePHP version 1.0 released in May 2006.  (source:http://en.wikipedia.org/wiki/CakePHP)
What Is The Current Stable Version Of CakePHP?
3.0 (on date 2015-06-12).
What Is MVC In CakePHP?
Model view controller (MVC) is an architectural pattern used in software engineering.
Model: Database functions exist in the model
View: Design parts written here
Controller: Business Logic goes here
MVC Architecture of CakePHP
Server Requirements For CakePHP
Here are the requirements for setting up a server to run CakePHP:
An HTTP server (like Apache) with the following enabled: sessions, mod_rewrite (not absolutely necessary but preferred)
PHP 4.3.2 or greater. Yes, CakePHP works great in either PHP 4 or 5.
A database engine (right now, there is support for MySQL 4+, PostgreSQL and a wrapper for ADODB).
How To Install CakePHP?
step1: Go to cakephp.org and download the latest version of cakephp.
step2: Cakephp comes in a .zip file,so unzip it.
step3: Extract the files in the localhost in the desired folder (for example:cakephp).
step4: Open the browser and run the URL localhost/cakephp
step5: Just Follow the instructions display on the page.
What Is The Folder Structure Of CakePHP?
·         cakephp/
·         app/
·         Config/
·         Console/
·         Controller/
·         Lib/
·         Locale/
·         Model/
·         Plugin/
·         Test/
·         tmp/
·         Vendor/
·         View/
·         webroot/
·         .htaccess
·         index.php
·         lib/
·         plugins/
·         vendors/
·         .htaccess/
·         index.php/
·         README.md/
What Is The Name Of Cakephp Database Configuration File Name And Its Location?
Default file name is database.php.default.
Its located at "/app/config/database.php.default".To connect with database it should be renamed to database.php
What Is the First File That Gets Loaded When You Run An Application Using Cakephp? Can You Change That File?
yes it can be changed.Either through index.php , or through .htaccess
What Is the Use Of Security.Salt And Security.CipherSeed In Cakephp? How to Change Its Default Value?
·         The Security.salt is used for generating hashes.we can change the default Security.salt value in /app/Config/core.php. 
·         The Security.cipherseed is used for encrypt/decrypt strings.We can change the default Security.cipherSeed value by editing /app/Config/core.php.
What Are Controllers?
A controller is used to manage the logic for a part of your application. Most commonly, controllers are used to manage the logic for a single model. Controllers can include any number of methods which are usually referred to as actions. Actions are controller methods used to display views. An action is a single method of a controller.
What Is Default Function For A Controller?
index() function
Which Function Is Executed Before Every Action In The Controller?
function beforeFilter()
List Some Of The Features In CakePHP
·         Compatible with versions 4 and 5 of PHP
·         MVC architecture
·         Built-in validations
·         Caching
·         Scaffolding
·         Access Control Lists and Authentication.
·         CSRF protection via Security Component.
Using cakephp, what all are drawbacks?
It loads full application before it starts your task. It's not recommended for small projects because of its resource-heavy structure.
What Is The Naming Convention In Cakephp?
Table names are plural and lowercased,model names are singular and CamelCased: ModelName, model filenames are singular and underscored: model_name.php, controller names are plural and CamelCased with *Controller* appended: ControllerNamesController, controller filenames are plural and underscored with *controller* appended: controller_names_controller.php,
What Is Scaffolding In Cakephp?
Scaffolding is a technique that allows a developer to define and create a basic application that can create, retrieve, update and delete objects.
How To Add Scaffolding In Your Application?
To add scaffolding to your application,just add the $scaffold variable in the controller,
class PostsController extends AppController {
    var $scaffold;
Assuming you’ve created Post model class file (in /app/Model/post.php), you’re ready to go. Visit http://example.com/posts to see your new scaffold.
What Is A Component In Cakephp?
Components are packages of logic that are shared between controllers. They are useful when a common logic or code is required between different controllers.
What Are Commonly Used Components Of Cakephp?
Access control lists
Request handling
What is a Helper?
Helpers in CakePHP are associated with Presentation layers of application.Helpers mainly contain presentational logic which is available to share between many views, elements, or layouts
What Are Commonly Used Helpers Of Cakephp?
·         FormHelper
·         HtmlHelper
·         JsHelper
·         CacheHelper
·         NumberHelper
·         Paginator
·         RSS
·         SessionHelper
·         TextHelper
·         TimeHelper
What Is A Behavior?
Behaviors in CakePHP are associated with Models.Behaviors are used to change the way models behaves and enforcing model to act as something else.
What Is the Difference Between Component, Helper, Behavior?
Component is a Controller extension, Helpers are View extensions, Behavior is a Model Extension.
What Is An Element?
Element in cakephp are smaller and reusable bits of view code. Elements are usually rendered inside views.
What Is a Layout?
Layout in cakephp are used to display the views that contain presentational code. In simple views are rendered inside a layout
How to Set Layout In The Controller?
var $layout = ‘layout_name’;
to overwrite for a specific action use below code in that action
$this->layout =”layout_name”;
How To Include Helpers In Controller?
public $helpers = array(‘Form’, ‘Html’, ‘Js’, ‘Time’);
to in specific action use below code in that action
$this->helper[] =”helper_name”;
How To Include Components In Controller ?
public $components = array(‘Emails’, ‘ImageUploader’, ‘Sms’);
How To Write, Read And Delete The Session In Cakephp?
$this->Session->write(‘Bird.Color’, ‘Black’);
$black = $this->Session->read(‘Bird.Color’);

What Is The Use Of $This->Set();
The set() method is used for creating a variable in the view file.Say for example if we write,
$this->set('posts',$posts); in controller fie, then the variable $posts will be available to use in the view template file for that action.
What Is The Use Of $This->Set(Compact());
Using $this->set(compact()) , we can pass multiple parameters to access into the view file.
For example,
Now all these variables will be available in respective view file.
What Are the Advantages of Each? Which Would You Use And Why?
An advantage with first case $this->set('posts', $posts); is that it allows two different names for the view file and controller file. For example, you could write something like $this->set('postData', $posts);. Now the variable name in the view file would be $postData.
The advantage with the second approach $this->set(compact()); is easier to write, and useful especially when we are setting several variables to the view.No need to add separate line for each variable as we have with $this->set();
For example,
Is It Possible To Have Multiple Validation Rules Per Field In Cakephp?
Yes, its possible.
What Is Wrong With The Below Validation Rule?
'email' => array(
    'rule' => array(
        'rule' => 'notEmpty',
        'message' => 'Please Enter Email address.'
    'rule' => array(
        'rule' => 'email',
        'message' => 'Entered Email address is invalid.'
The problem is the first rule notEmpty will never be called because email rule will overwrite it.While using multiple validation rules for the same field you must keep the rule key "unique". In this case if we want to use multiple rules then, we can simple change the rule key names like,
'email' => array(
    'rule1' => array(
        'rule' => 'notEmpty',
        'message' => 'Please Enter Email address.'
    'rule2' => array(
        'rule' => 'email',
        'message' => 'Entered Email address is invalid.'
How To Get Current URL In CakePHP?
To get current url in cakephp use,
echo Router::url($this->here, true);
This will give full URL with hostname.If you want to get relative path instead of full URL,then use the following code:
echo $this->here;
This will produce absolute URL excluding hostname i.e. /controller/abc/xyz/
How Can You Make Urls Search Engine Friendly While Using Cakephp?
It's an automatic task that is done by cakephp.
Can You List Some Database Related Functions In Cakephp?
find, findAll , findAllBy , findBy , findNeighbours and query.

Which Methods Are Used To Create And Destroy Model Associations On The Fly?

The bindModel() and unbindModel() Model methods are used to create and destroy model associations on the fly.
Request to Download PDF

Post A Comment: