Here we’ll discuss about some basic and advanced cakephp interview questions and answers which are most ask-able questions during interview session, These CakePHP questions and answers will help you to crack CakePHP technical interview round.
Question: What is Cakephp?
CakePHP is a free, open-source, MVC (Model, View, Controller) rapid development framework for PHP. It’s a framework which help you to make development fast and secure. CakePHP goal is to enable developers to work in a structured and rapid manner–without loss of flexibility.
Question: What is MVC in CakePHP?
Model view controller (MVC) is an architectural pattern used in software engineering.
Model: Handle database related functionality, manipulating database related query like add, edit , delete.
View: Design parts written here (HTML+PHP)
Controller: Business Logic goes here
Question: What Is The Name Of Cakephp Database Configuration File Name And Its Location?
FileName: database.php.default
Location: /app/config/database.php.default
Question: What is First cakphpe file loaded in application?
bootstrap.php
Question: 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/
Question:What Is The Use Of Security.Salt And Security.CipherSeed In Cakephp?
The Security.salt is used for generating hashes.
The Security.cipherseed is used for encrypt/decrypt strings.
Question: What is default function for a controller?
function index() is default function in controller.
Question:Which function is executed before every action in the controller?
function beforeFilter()
Question: What Is Scaffolding In Cakephp?
Scaffolding is a technical way that allows a developer to define and create a basic application that can create, retrieve, update and delete objects.
Question: List some of the features in CakePHP?
* MVC architecture
* In-Built validations
* Caching
* Scaffolding
* CSRF protection via Security Component.
* Access Control Lists and Authentication and creating role management system.
Question: How to add Scaffolding in your application?
By adding $scaffold variable in the controller see following example.
<?php
class PostsController extends AppController {
var $scaffold;
}
?>
Question: How To Include Components In Controller?
echo $this->here;
Question: How To Get Controller Name In CakePHP Views?
$this->request->params['controller']
Question: How To Get Controller Action Name In CakePHP Views?
$this->request->params['action']
Question: Which Methods Are Used To bind And Destroy Model Associations?
bindModel() : used to bind Model Associations
unbindModel() : used to destroy Model Associations
Question: What Is The Default Extension Of view files In Cakephp?
.ctp
Question: What is a Helper in CakePHP?
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
Question:What is a Behavior in CakePHP?
Behaviors in CakePHP are associated with Models.Behaviors are used to change the way models behaves and enforcing model to act as something else.
Question: What is the difference between Component, Helper, Behavior?
Component is a Controller extension, Helpers are View extensions, Behavior is a Model Extension.
Question: How to set variables for views?
$this->set('name','Cake PHP');
Question: How to set layout for controller
By adding $layout variable in the controller see following example.
<?php
class PostsController extends AppController {
public $layout = 'layoutname';
}
?>
Setting layout for particular action,
layout = ‘layoutname’;
}
}
?>
Question: How to write, read and delete the Session in cakephp?
$this->Session->write(‘User.name’, ‘Rohit Kumar’);
$black = $this->Session->read(‘User.name’);
$this->Session->delete(‘User’);
Question: What is Cakephp?
CakePHP is a free, open-source, MVC (Model, View, Controller) rapid development framework for PHP. It’s a framework which help you to make development fast and secure. CakePHP goal is to enable developers to work in a structured and rapid manner–without loss of flexibility.
Question: What is MVC in CakePHP?
Model view controller (MVC) is an architectural pattern used in software engineering.
Model: Handle database related functionality, manipulating database related query like add, edit , delete.
View: Design parts written here (HTML+PHP)
Controller: Business Logic goes here
Question: What Is The Name Of Cakephp Database Configuration File Name And Its Location?
FileName: database.php.default
Location: /app/config/database.php.default
Question: What is First cakphpe file loaded in application?
bootstrap.php
Question: 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/
Question:What Is The Use Of Security.Salt And Security.CipherSeed In Cakephp?
The Security.salt is used for generating hashes.
The Security.cipherseed is used for encrypt/decrypt strings.
Question: What is default function for a controller?
function index() is default function in controller.
Question:Which function is executed before every action in the controller?
function beforeFilter()
Question: What Is Scaffolding In Cakephp?
Scaffolding is a technical way that allows a developer to define and create a basic application that can create, retrieve, update and delete objects.
Question: List some of the features in CakePHP?
* MVC architecture
* In-Built validations
* Caching
* Scaffolding
* CSRF protection via Security Component.
* Access Control Lists and Authentication and creating role management system.
Question: How to add Scaffolding in your application?
By adding $scaffold variable in the controller see following example.
<?php
class PostsController extends AppController {
var $scaffold;
}
?>
Question: How To Include Components In Controller?
echo $this->here;
Question: How To Get Controller Name In CakePHP Views?
$this->request->params['controller']
Question: How To Get Controller Action Name In CakePHP Views?
$this->request->params['action']
Question: Which Methods Are Used To bind And Destroy Model Associations?
bindModel() : used to bind Model Associations
unbindModel() : used to destroy Model Associations
Question: What Is The Default Extension Of view files In Cakephp?
.ctp
Question: What is a Helper in CakePHP?
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
Question:What is a Behavior in CakePHP?
Behaviors in CakePHP are associated with Models.Behaviors are used to change the way models behaves and enforcing model to act as something else.
Question: What is the difference between Component, Helper, Behavior?
Component is a Controller extension, Helpers are View extensions, Behavior is a Model Extension.
Question: How to set variables for views?
$this->set('name','Cake PHP');
Question: How to set layout for controller
By adding $layout variable in the controller see following example.
<?php
class PostsController extends AppController {
public $layout = 'layoutname';
}
?>
Setting layout for particular action,
layout = ‘layoutname’;
}
}
?>
Question: How to write, read and delete the Session in cakephp?
$this->Session->write(‘User.name’, ‘Rohit Kumar’);
$black = $this->Session->read(‘User.name’);
$this->Session->delete(‘User’);