Here we have mentioned most frequently asked CakePHP Interview Questions and Answers specially for freshers and experienced.


 

1. What is CakePHP ?

Ans:

CakePHP is an open-source free web framework written in PHP scripting Language for rapid web development. CakePHP follows the model–view–controller (MVC) approach and modeled after the concepts of Ruby on Rails, and distributed under the MIT License.

2. List minimum server requirements to install CakePHP ?

Ans:

Minimum server requirements to install CakePHP 3.4.0
HTTP Server. For example Apache. Having mod_rewrite is preferred, but by no means required.
PHP 5.6.0 or greater (including PHP 7.1).
mbstring PHP extension installed and enabled
intl PHP extension
simplexml PHP extension

3. Please provide Controllers naming convention in CakePHP ?

Ans:

In CakePHP Controllers names are Caps, camel case, ends with “Controller”
Example: AccountSummaryController

4. What is Composer? How to create a CakePHP Project using Composer?

Ans:

Composer is a tool for managing project dependencies. You can create a CakePHP project using Composer by running below commands on terminal.
php composer.phar create-project –prefer-dist cakephp/app my_app_name

5. What is name of default function and controller of CakePHP which is called automatically?

Ans:

In CakePHP Default controller is indexController.php and Default function is index.

6. What are sessions in PHP . How to read, write and delete session in cakephp ?

Ans:

Session in PHP
PHP Sessions allows you to identify unique users across requests and store persistent data for specific users against a unique session ID. This can be used to persist state information between page requests. Session IDs are normally sent to the browser via session cookies and the ID is used to retrieve existing session data.
Reading, Writing and Deleting session in Cakephp 3.x
You can access the session data any place you have access to a request object. This means the session is accessible from:

  • Controllers
  • Views
  • Helpers
  • Cells
  • Components

In addition to the basic session object, you can also use the Cake\View\Helper\SessionHelper to interact with the session in your views. A basic example of session usage would be:

$name = $this->request->session()->read('User.name');
// If you are accessing the session multiple times,
// you will probably want a local variable.
$session = $this->request->session();
$name = $session->read('User.name');
Reading, Writing and Deleting Session Data
Session::read($key) function is used to read specific session data in CakePHP.
Session::write($key, $value) function is used to write session data in CakePHP.
Session::delete($key) function is used to delete specific session data in CakePHP.
Sample Usage
//Reading a session
$session->read('Config.language');
//Writing a session
$session->write('Config.language', 'en');
//Deleting a session
$session->delete('Some.value');

7. What is the name of CakePHP database configuration file ?

Ans:

database.php.default file is used for database configuration in CakePHP. It is located in /app/config/ directory of CakePHP

8. List some features of CakePHP framework ?

Ans:

Top features of CakePHP framework

  • MVC Architecture
  • Zero configuration
  • Inbuilt validation
  • ACL Functionality and Security
  • CRUD scaffolding
  • Easily extendable with plug-ins
  • Quick and flexible

9. How to use Pagination in CakePHP ?

Ans:

Pagination in CakePHP
In CakePHP controller Pagination component is used to building paginated queries. In order to generate pagination links & buttons in view PaginatorHelper is used
Below are sample pagination usage code in CakePHP
Pagination in Controller

class PostsController extends AppController
{
public $paginate = [
'limit' => 25,
'order' => [
'Posts.id' => 'desc'
]
];
public function initialize()
{
parent::initialize();
$this->loadComponent('Paginator');
$this->loadHelper('Paginator', ['templates' => 'MyPlugin.paginator-templates']);
}
public function display(){
$this->set('posts', $this->paginate());
}
}
Pagination in CakePHP Views
$paginator = $this->Paginator;
if($posts){
//creating our table
echo "

“; // our table header, we can sort the data user the paginator sort() method! echo “”; // in the sort method, there first parameter is the same as the column name in our table
// the second parameter is the header label we want to display in the view
echo “”;
echo “”;
echo “”;
echo “”;
// loop through the user’s records
foreach( $posts as $post ){
echo “”; echo “”;
echo “”;
echo “”;
echo “”;
}
echo “

” . $paginator->sort(‘id’, ‘ID’) . “” . $paginator->sort(‘title’, ‘Title’) . “” . $paginator->sort(‘published_on’, ‘Published on’) . “
{$post[‘Post’][‘id’]}{$post[‘Post’][‘title’]}{$post[‘Post’][‘published_on’]}

“;
// pagination section
echo “

“;
// the ‘first’ page button
echo $paginator->first(“First”);
// ‘prev’ page button,
// we can check using the paginator hasPrev() method if there’s a previous page
// save with the ‘next’ page button
if($paginator->hasPrev()){
echo $paginator->prev(“Prev”);
}
// the ‘number’ page buttons
echo $paginator->numbers(array(‘modulus’ => 2));
// for the ‘next’ button
if($paginator->hasNext()){
echo $paginator->next(“Next”);
}
// the ‘last’ page button
echo $paginator->last(“Last”);
echo “

“;
}
// tell the user there’s no records found
else{
echo “No posts found.”;
}
?>

10. List different type of Cache CakePHP Supports ?

Ans:

CakePHP supports Cache out of the box.Below are the list of Cache engines supported by CakePHP.

  • APCu
  • File Based
  • Memcached
  • Redis
  • Wincache
  • XCache


 

11. How to get current URL in CakePHP ?

Ans:

In Cakephp 2.x you can get current url in view by using $this->here; or Router::url( $this->here, true );
In Cakephp 3.x you can get current url in view by using $this->Url->build(null, true);

12. What is MVC in CakePHP ?

Ans:

CakePHP works on MVC structure.
MVC stands for model view controller.MVC is not a design pattern, it is an architectural pattern that describes a way to structure our application and explains responsibilities and interactions of each part in that structure:
Model: Wraps up data and logics of CakePHP.
View: Handles output and presentation to User.
Controller: Manipulates the data from models and generates or pass it to views.

13. What are components in CakePHP. List some commonly used CakePHP components ?

Ans:

In CakePHP, components are packages of logic that are shared between controllers. CakePHP comes with a fantastic set of core components you can use to aid in various common tasks.Using component in your application makes your controller code cleaner and allows you to reuse code between different controllers.
Below are the list some commonly used CakePHP components

  • Authentication
  • Cookie
  • Cross Site Request Forgery
  • Flash
  • Security
  • Pagination
  • Request Handling

14. What are Hooks in CakePHP?

Ans:

CakePHP hooks are callback functions that are called before or after a model operation.We define these functions in our Model classes.
Below is the list of some hooks or callback functions provided by CakePHP.
beforeFind
afterFind
beforeValidate
afterValidate
beforeSave
afterSave
beforeDelete
afterDelete
onError

15. List Types of association supported by CakePHP?

Ans:

There are four association supported by CakePHP they are:
hasOne:One to One Relationship
hasMany:One to many Relationship
belongsTo:Many to One Relationship
hasAndBelongsToMany (HABTM):Many to Many Relationship

16. What is Cakephp?

Ans:

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.

17. When CakePHP was developed?

Ans:

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)

18. What is the current stable version of CakePHP?

Ans:

3.4 (on date 2017-04-01).

19. What is MVC in CakePHP?

Ans:

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

20. MVC Architecture of CakePHP

Ans:

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).




 

21. How to install CakePHP?

Ans:

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.

22. What is the folder structure of CakePHP?

Ans:

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/

23. What is the name of Cakephp database configuration file name and its location?

Ans:

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

24. What is the first file that gets loaded when you run a application using cakephp?can you change that file?

Ans:

bootstrap.php
yes it can be changed.Either through index.php , or through .htaccess

25. What is the use of Security.salt and Security.cipherSeed in cakephp? How to change its default value?

Ans:

– 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.

26. What are controllers?

Ans:

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.

27. What is default function for a controller?

Ans:

index() function

28. Which function is executed before every action in the controller?

Ans:

function beforeFilter()

29. List some of the features in CakePHP

Ans:

  1. Compatible with versions 4 and 5 of PHP
  2. MVC architecture
  3. Built-in validations
  4. Caching
  5. Scaffolding
  6. Access Control Lists and Authentication.
  7. 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.

30. What is the naming convention in cakephp?

Ans:

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,


 

31. What is Scaffolding in Cakephp?

Ans:

Scaffolding is a technique that allows a developer to define and create a basic application that can create, retrieve, update and delete objects.

32. How to add Scaffolding in your application?

Ans:

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.

33. What is a Component in cakephp?

Ans:

Components are packages of logic that are shared between controllers. They are useful when a common logic or code is required between different controllers.

34. What are commonly used components of cakephp?

Ans:

  1. Security
  2. Sessions
  3. Access control lists
  4. Emails
  5. Cookies
  6. Authentication
  7. Request handling
  8. Scaffolding

35. What is a Helper?

Ans:

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

36. What are commonly used helpers of cakephp?

Ans:

FormHelper
HtmlHelper
JsHelper
CacheHelper
NumberHelper
Paginator
RSS
SessionHelper
TextHelper
TimeHelper

37. What is a Behavior?

Ans:

Behaviors in CakePHP are associated with Models.Behaviors are used to change the way models behaves and enforcing model to act as something else.

38. What is the difference between Component, Helper, Behavior?

Ans:

Component is a Controller extension, Helpers are View extensions, Behavior is a Model Extension.

39. What is a Element?

Ans:

Element in cakephp are smaller and reusable bits of view code. Elements are usually rendered inside views.

40. What is a layout?

Ans:

Layout in cakephp are used to display the views that contain presentational code. In simple views are rendered inside a layout



 

41. How to set layout in the controller?

Ans:

var $layout = ‘layout_name’;
to overwrite for a specific action use below code in that action
$this->layout =”layout_name”;

42. How to include helpers in controller ?

Ans:

public $helpers = array(‘Form’, ‘Html’, ‘Js’, ‘Time’);
to in specific action use below code in that action
$this->helper[] =”helper_name”;

43. How to include components in controller ?

Ans:

public $components = array(‘Emails’, ‘ImageUploader’, ‘Sms’);

44. How to write, read and delete the Session in cakephp?

Ans:

$this->Session->write(‘Bird.Color’, ‘Black’);
$black = $this->Session->read(‘Bird.Color’);
$this->Session->delete(‘Bird’);

45. What is the use of $this->set();

Ans:

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.

46. What is the use of $this->set(compact());

Ans:

Using $this->set(compact()) , we can pass multiple parameters to access into the view file.

For example,
$this->set(compact(‘posts’,’users’,’reports’));
Now all these variables will be available in respective view file.

47. What are the advantages of each?which would you use and why?

Ans:

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,
$this->set(compact(‘posts’,’users’,’reports’));

48. Is it possible to have Multiple validation Rules per Field in cakephp?

Ans:

Yes its possible.

49. What is wrong with the below validation rule?

Ans:

'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.'
)
)

50. What is the difference between required and notEmpty in cakephp?

Ans:

Difference between required and notEmpty




 

51. How to Get current URL in CakePHP?

Ans:

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/

52. How can you make urls search engine friendly while using cakephp?

Ans:

It’s an automatic task that is done by cakephp.

53. Can you list some database related functions in cakephp?

Ans:

find, findAll , findAllBy , findBy , findNeighbours and query.

54. Which methods are used to create and destroy model associations on the fly?

Ans:

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

55. What is the use of requestAction method?

Ans:

The method requestAction is used to call a controller’s action from any location and returns data from the action.

56. What is recursive in cakephp?

Ans:

To understand this topic follow this post :
Recursive in cakephp

57. How can we use ajax in cakephp?

Ans:

By calling ajax helper and then using it in controller for rendering.

58. What is habtm?

Ans:

Has and belongs to many is a kind of associations that can be defined in models for retrieving associated data across different entities.

59. How cakephp URL looks in address bar?

Ans:

http://example.com/controller/action/param1/param2/param3

60. How can you include a javascript menu throughout the site. Give steps.

Ans:

By adding the javascript files in webroot and call them in default views if needed everywhere or just in the related veiws.


 

61. Why cakephp have two vendor folder?what is the difference between two vendors folder available in cakephp?

Ans:

There will be two vendor folders available in cakephp frame work.
one in ” app ” folder and one in root folder
The vendor folder in the app folder is used to place the third-party libraries which are application specific.
The vendor folder in the root folder is used to place the third-party libraries which are used for multiple applications.

62. What is the default extension of view files in cakephp?can we change it?if yes then how?

Ans:

default extension of view files is ‘.ctp’.
yes we can change it by writing public $ext = ‘.yourext’; in AppController.If you want to change it for particular controller then add it into that controller only.You can also change it for the specific action of the controller by putting it in that action of controller.
public $ext = ‘.yourext’; in AppController
– you can change all the views extentions.

public $ext = ‘.yourext’; in specific controller like, PostsController
– you can change all the views extentions of PostsController.

public $ext = ‘.yourext’; in specific controller action like, index()
– you can change the view extention of index.ctp

Note: You cannot specify multiple extensions, however it seems like there is a fall back to .ctp if no .php file is found.

63. How can you set custom page title for the static page?

Ans:

To set a custom page title, copy-paste following code anywhere in your static page (.ctp) file:
$this->set(“title_for_layout”, “My page title”);

64. How to display the schema of the model?

Ans:

If you want to display the schema of particular model then you just need to add the following single line of code.For example we have “Posts” Controller.
pr($this->Post->schema());

65. What is MVC in CakePHP?

Ans:

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

66. What Is The Name Of Cakephp Database Configuration File Name And Its Location?

Ans:

FileName: database.php.default
Location: /app/config/database.php.default

67. What is First cakphpe file loaded in application?

Ans:

bootstrap.php

68. What is the folder structure of CakePHP?

Ans:

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/

69. What Is The Use Of Security.Salt And Security.CipherSeed In Cakephp?

Ans:

The Security.salt is used for generating hashes.
The Security.cipherseed is used for encrypt/decrypt strings.

70. What is default function for a controller?

Ans:

function index() is default function in controller.



 

71. Which function is executed before every action in the controller?

Ans:

function beforeFilter()

72. What Is Scaffolding In Cakephp?

Ans:

Scaffolding is a technical way that allows a developer to define and create a basic application that can create, retrieve, update and delete objects.

73. List some of the features in CakePHP?

Ans:

* MVC architecture
* In-Built validations
* Caching
* Scaffolding
* CSRF protection via Security Component.
* Access Control Lists and Authentication and creating role management system.

74. How to add Scaffolding in your application?

Ans:

By adding $scaffold variable in the controller see following example.

class PostsController extends AppController {
var $scaffold;
}
?>

75. How To Include Components In Controller?

Ans:

class PostsController extends AppController {
public $components = array('Emails', 'Paging', 'HTML2PDF');
}
?>

76. How To Get Current URL In CakePHP?

Ans:

echo $this->here;

77. How To Get Controller Action Name In CakePHP Views?

Ans:

$this->request->params[‘action’]

78. What Is The Default Extension Of view files In Cakephp?

Ans:

.ctp

79. What is a Helper in CakePHP?

Ans:

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

80. What is a Behavior in CakePHP?

Ans:

Behaviors in CakePHP are associated with Models.Behaviors are used to change the way models behaves and enforcing model to act as something else.




 

81. What is the difference between Component, Helper, Behavior?

Ans:

Component is a Controller extension, Helpers are View extensions, Behavior is a Model Extension.

82. How to set variables for views?

Ans:

$this->set(‘name’,’Rohit Kumar’);

83. How to set layout for controller

Ans:

By adding $layout variable in the controller see following example.

class PostsController extends AppController {
public $layout = 'layoutname';
}
?>
Setting layout for particular action,
layout = ‘layoutname’;
}
}
?>

84. How to write, read and delete the Session in cakephp?

Ans:

$this->Session->write(‘User.name’, ‘Rohit Kumar’);
$black = $this->Session->read(‘User.name’);
$this->Session->delete(‘User’);

85. What Is The Current Stable Version Of CakePHP?

Ans:

3.1.1 / 6 October 2015

86. What are the System requirement for cakephp3.0

Ans:

PHP 5.4.16 or greater.
mbstring extension
intl extension
MySQL (5.1.10 or greater)

87. What Is The Name Of Cakephp Database Configuration File Name And Its Location

Ans:

FileName: database.php.default
Location: /app/config/database.php.default

88. What is First cakphpe file loaded in application?

Ans:

bootstrap.php
Also, We can change its file through index.php file which loaded earlier.

89. What Is The Use Of Security.Salt And Security.CipherSeed In Cakephp?

Ans:

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.

90. What Is Default Function For A Controller?

Ans:

index() function


 

91. Which Function Is Executed Before Every Action In The Controller?

Ans:

beforeFilter() function

92. List Some Of The Features In CakePHP?

Ans:

1. MVC architecture
2. Built-in validations
3. Caching
4. Scaffolding
5. Auth & ACL
6. CSRF protection via Security Component.

93. What Is Scaffolding In Cakephp?

Ans:

Scaffolding is a technical way that allows a developer to define and create a basic application that can create, retrieve, update and delete objects.

94. How To Add Scaffolding In Your Application?

Ans:

var $scaffold;

95. How To Include Components In Controller?

Ans:

public $components = array(‘Emails’, ‘ImageUploader’);

96. What is callback functions in Cakephp? Please explain?

Ans:

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.

97. How callback functions works in CakePHP?

Ans:

/** In controller**/
$userData = array();
$this->User->InsertRecord($userData );
/** In controller**/
/** In model **/
function InsertRecord($userData){
$this->save($userData);
}
function beforeSave(){
}
function AfterSave(){
}
/** In model **/

98. What are associations in CakePHP? What are different types of associations?

Ans:

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.

99. How To Get Current URL In CakePHP?

Ans:

echo $this->here;

100. Which Methods Are Used To Create And Destroy Model Associations?

Ans:

bindModel() used to create Model Associations
unbindModel() used to destroy Model Associations



 

101. What Is The Use Of RequestAction Method?

Ans:

Its used to a call controller action from any location and returns data from the that action.

102. How Can We Use Ajax In Cakephp?

Ans:

Use ajax helper.

103. What Is The Default Extension Of view files In Cakephp?

Ans:

.ctp

104. How to set Meta title from view files?

Ans:

$this->set(“title_for_layout”, “This is page meta title”);

105. What is Cakephp?

Ans:

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.

106. When CakePHP was developed?

Ans:

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)

107. When CakePHP was developed?

Ans:

April 2005

108. What is current Stable version of cakePHP?

Ans:

3.1.5 / 30 November 2015

109. For cakPHP 3.1.5 installtion, what is minimum PHP Version required?

Ans:

PHP 5.4

110. What are are drawbacks of cakephp.

Ans:

The learning curve, and it loads full application before it starts your task. Its not recommended for small projects because of its resource heavy structure.




 

111. What is MVC (model, view, and controller) in cakephp?

Ans:

Model–view–controller (MVC) is an architectural pattern used in software engineering.
Model: Databases function exist in the model
View: Design parts written here
Controller: Business Login

112. What is the name of Cakephp database configuration file name and its location?

Ans:

Default file name is database.php.default.
Its located in “/app/config/database.php.defaut”

113. What are component, helper and why are they used?

Ans:

A component is an independent piece of code written for specific task that can be used(Eg Email, Ajax, RequestHandler and Session).
A helper is used for helping cakephp in rendering the data to be shown to user with views(Eg Form, HTML etc).

114. What are commonly used components of cakephp?

Ans:

Following are some components which is used in cakephp.

· Security
· Sessions
· ACL(Access control lists)
· Auth(Authentication)
· Emails
· Cookies
· RequestHandling
· MVC architecture
· Built-in validations
· Caching
· scaffolding

115. What is HABTM.

Ans:

Full form of Has And Belongs To Many.
It is a kind of associations that can be defined in models for retrieving associated data across different entities.
For Example
A product have one or more tags, and a tag may belongs to one or more product.

/**
* Post Model
*
* @property Tag $Tag
*/
class Post extends AppModel {

/**
* Display field
*
* @var string
*/
public $displayField = ‘name’;

/**
* Validation rules
*
* @var array
*/
public $validate = array( );

/**
* hasAndBelongsToMany associations
*
* @var array
*/
public $hasAndBelongsToMany = array(
‘Tag’ => array(
‘className’ => ‘Tag’,
‘joinTable’ => ‘posts_tags’,
‘foreignKey’ => ‘post_id’,
‘associationForeignKey’ => ‘tag_id’,
‘unique’ => ‘keepExisting’,
)
);

}

116. What is default function and default controller of cakephp which is called automatically?

Ans:

Default controller is indexController.php and Default function is index.

117. How cakephp URL looks in address bar

Ans:

http://example.com/controller/action/param1/param2/param3

118. Why cakephp have two vendor folder?

Ans:

There is two vendor folder, one folder in root and another is in “app” folder

119. List some database related functions in cakephp.

Ans:

find, findAll , findAllBy , findBy , findNeighbours and query.

120. List some of the features in Cakephp

Ans:

Following are some feature of Cakephp.
· Full support of (MVC)Model, View, Controller Architecture.
· Scaffolding.
· Very nice Code generation via Bake.
· Helpers for HTML, Forms, Pagination, AJAX, Javascript, XML, RSS and more.
· Access Control Lists and Authentication (ACL & Auth).
· Router for mapping urls and handling extensions.
· Security, Session, and RequestHandler Components.
· Utility classes for working with Files, Folders, Arrays and more.
· can manage multiple site(apps) developement.
· Internationalization and Localization with static translations in gettext style or dynamic translations of model data.
· Full Console environment with support for multiple tasks. Included shells: bake, schema, acl, i18 extractor, api.
· CSRF protection via Security Component.
· HTTP Authentication via Security Component.
· Flexible Caching: use memcache, apc, xcache, the file system, or a model to speed up your application
· Configure class to provide dynamic handling of configuration settings and App class to handle importing required classes.
· Now Supports Unit Testing application.
· Integration with Crusecontrol and Ant.


 

121. list some of the features in Cakephp

Ans:

Following are some feature of Cakephp.
MVC architecture
Built-in validations
Caching
scaffolding

122. How To Get Controller Name In CakePHP Views?

Ans:

$this->request->params[‘controller’]

123. Which Methods Are Used To bind And Destroy Model Associations?

Ans:

bindModel() : used to bind Model Associations
unbindModel() : used to destroy Model Associations

124. What Is A Behavior?

Ans:

Behaviors in CakePHP are associated with Models.