Here there are some Cakephp interview questions and answers about How CakePHP Framework works. These cakephp interview questions listed below are mainly asked in any interview. These cakephp interview questions are use full both fresher and experienced people.
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.
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).
Installation of cakephp
01. Go to cakephp.org and download the latest version of cakephp.
02. Cakephp comes in a .zip file so unzip it.
03. Extract the files in the localhost in the desired folder ( lets say cakephp)
04. Open the browser and run the URL localhost/cakephp
05. Follow the instruction showed in the page
what is the folder structure of Cakephp
List some of the features in Cakephp?
Basic Features List
- Full support of Model, View, Controller Architecture.
- Good Application Scaffolding.
- Very nice Code generation via Bake.
- Access Control Lists and Authentication.
- 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
Advance Features List
- 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 applicationConfigure class to provide dynamic handling of configuration settings and App class to handle importing required classes. Supports Unit Testing (simpletest,unit test)
what is the difference between two vendors folder available in cakephp?
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.
what is the naming convention in cakephp.
According to cakephp naming conventions
1) Table names should be in lowercase and always Plural
2) Model name should be in CamelCased and are always singular eg: ModelName
3) Model file names are also singular and underscored if contains two words eg : model_name.php
4) Controller name should be in CamelCased and are always plural : appended “controller ” eg: ControllerNamesController
5) Controller file names are always plural and underscored : appender “controller” eg: controller_names_controller.php
what is model,view,controller?
1. The Model represents the application data
2. The View renders a presentation of model data
3. The Controller handles and routes requests made by the client
what is a component?
Components in CakePHP are associated with Controllers.
Components are created and used to share common functionality bewteen controllers.
What are commonly used components of cakephp?
3. Access control lists
7. Request handling
what is a Helper?
Helpers in CakePHP are associated with Presentation layers of application.
Helpers mainly contain presentational logic which is availabel to share between many views, elements, or layouts
What are commonly used helpers of cakephp?
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.
Difference between Component, Helper, Behavior?
Component is a Controller extension, Helpers are View extensions, Behavior is a Model Extension.
What is a 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
what is the first function that gets loaded from a controller?
In which file cake php database configuration is setup ?
The four model association types in CakePHP are
4) hasAndBelongsToMany (HABTM).
Database related functions in cakephp.
How to set layout in the controller?
var $layout = ‘layout_name’;
to overwrite for a specific action use below code in that action
How to including helpers in controller ?
public $helpers = array(‘Form’, ‘Html’, ‘Js’, ‘Time’);
to in specific action use below code in that action
How to including components in controller ?
public $components = array(‘Emails’, ‘ImageUploader’, ‘Sms’);
Session write, read and delete
2)$green = $this->Session->read(‘Person.eyeColor’);
Which function is executed before every action in the controller?
requestAction is used to ?
To call controller function form view requestAction function is used
$abc = $this->requestAction(‘/controller/action/param:1234’);
$abc = $this->requestAction(‘controller’=>’controller_name’, ‘action’=>’action_name’, ‘param’ => 1234);
what all are drawbacks?
1) The biggest drawback to CakePHP is that it doesn’t completely implement object orientation
2) Can’t be used for small scale apps as it loads the complete application in beginning.
3) The learning curve