Monday, 26 October 2015

CakePHP Interview Questions and Answers for experienced

CakePHP Interview Questions and Answers for experienced



Question: What Is The Current Stable Version Of CakePHP?
3.1.1 / 6 October 2015

Question: What are the System requirement for cakephp3.0
PHP 5.4.16 or greater.
mbstring extension
intl extension
MySQL (5.1.10 or greater)


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
Also, We can change its file through index.php file which loaded earlier.


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.
You can change the above values from /app/Config/core.php.

Question: What Is Default Function For A Controller?
index() function


Question: Which Function Is Executed Before Every Action In The Controller?
beforeFilter() function


Question: List Some Of The Features In CakePHP?
  1. MVC architecture
  2. Built-in validations
  3. Caching
  4. Scaffolding
  5. Auth & ACL
  6. CSRF protection via Security Component.


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: How To Add Scaffolding In Your Application?
var $scaffold;
Add above In Controller Question: What Is A Behavior?
Behaviors in CakePHP are associated with Models.


Question: How To Include Components In Controller?
public $components = array('Emails', 'ImageUploader');


Question: What is callback functions in Cakephp? Please explain?
Callback functions are simple functions which called automatically when are defined by the core cakephp.
Suppose you are inserting record in your database. Now you have two requirement.
1. Validate the data before inserting into database.
2. Want to do some changes after inserting into database.


Question: How callback functions works in CakePHP?
/** In controller**/
$userData = array();
$this->User->InsertRecord($userData );
/** In controller**/

/** In model **/
function InsertRecord($userData){
    $this->save($userData);
}

function beforeSave(){
}

function AfterSave(){
}
/** In model **/



Question: What are associations in CakePHP? What are different types of associations?
Associations are the terms which means getting the data from database which are in different tables.


Relationship Association Type Example in Single Line
one to one hasOne A user has one profile.
one to many hasMany A user can have multiple recipes.
many to one belongsTo Many recipes belong to a user.
many to many hasAndBelongsToMany Recipes have, and belong to, many ingredients.

When Models's save function going to called, beforeSave will be called then AfterSave.




Question: How To Get Current URL In CakePHP?
echo $this->here;

Question: Which Methods Are Used To Create And Destroy Model Associations?
bindModel() used to create Model Associations
unbindModel() used to destroy Model Associations


Question: What Is The Use Of RequestAction Method?
Its used to a call controller action from any location and returns data from the that action.


Question: How Can We Use Ajax In Cakephp?
Use ajax helper.


Question: What Is The Default Extension Of view files In Cakephp?
.ctp



Question: What Is folder structure of cakePHP?
What Is folder structure of cakePHP




Question: How to set Meta title from view files?
$this->set("title_for_layout", "This is page meta title");