CakePHP interview questions and answers

CakePHP interview questions

CakePHP  is a free, open-source, rapid development framework for PHP. It’s a foundational structure for programmers to create web applications. There is number of in built component like Ajax, RequestHandler, Session etc.

Question: What are the drawbacks of cakephp?
Answer : 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.

Question : What is the name of Cakephp database configuration file name and its location?
Answer: Default file name is database.php.default.
It is located in “/app/config/database.php.defaut”.

Question : What is MVC (model, view, and controller) in cakephp?
Answer : 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 Logic

Question : What are component, helper and why are they used?
Answer: 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).

Question : What are commonly used components of cakephp?
Answer: 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

Question : List some of the features in Cakephp.
Answer: Following are some feature of Cakephp.
-MVC architecture
-Built-in validations
-Caching
-Scaffolding

Question : List some database related functions in cakephp.
Answer: find, findAll , findAllBy , findBy , findNeighbours and query.

Question : What are two vendor folders in cakephp?
Answer: There is two vendor folder, one folder in root and another is in “app” folder.

Question : How cakephp URL looks in address bar?
Answer:

Question : What is default function and default controller of cakephp which is called automatically?
Answer: Default controller is indexController.php and Default function is index.

Question: What is HABTM?
Answer: 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.

Read Also: How To Prepare for Web Designer Interview Questions and Answers.

Question: What is the directory structure when you download cakephp?
Answer:
* app/
– config/
– controllers/
– models/
– plugins/
– tmp/
– vendors/
– views/
– webroot/
* cake/
– config/
– docs/
– libs/
* vendors/

Question: What is the first file that gets loaded when you run a application using cakephp? Can you change that file?
Answer: bootstrap.php, yes it can be changed, either through index.php, or through htaccess.

Question: Why cakephp, and why not any other framework?
Answer: It has been for years in the market with strong support in the form of communities and online documentation, it supports php 4/5.

Question: How can we use ajax in cakephp?
Answer: By calling ajax helper and then using it in controller for rendering.

Question: What is the naming convention in cakephp?
Answer: 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.

Question: What is Scaffolding in Cakephp?
Answer: Scaffolding is a technique that allows a developer to define and create a basic application that can create, retrieve, update and delete objects.

Question: What is meant by MVC?
Answer: model view controller, it is a software architecture, used to isolates business logic from presentation logic. cakephp is based on mvc pattern.

Question: What are 3 important parts of MVC?
Answer:
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

Question: What are controllers?
Answer: 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.

Question: What is default function for a controller?
Answer: index() function

Question: What is a Component in cakephp?
Answer: Components are packages of logic that are shared between controllers. They are useful when a common logic or code is required between different controllers.

Question: What are commonly used components of cakephp?
Answer:
* Security
* Sessions
* Access control lists
* Emails
* Cookies
* Authentication
* Request handling

Question: In cakephp can you call a model from view?
Answer:
App::import(‘Model’, ‘Price’);
$prc = new Price();

Question : How can you include a javascript menu throughout the site?
Answer : By adding the javascript files in webroot and call them in default views if needed everywhere or just in the related veiws.

Question : How can you make urls search engine friendly while using cakephp?
Answer : it is an automatic task that is done by cakephp.

Question : Which function is first executed before every action in the controller ?
Answer: beforeFilter() is a action which is executed before every action in the controller.

3 thoughts on “CakePHP interview questions and answers”

  1. Appreciations for writing such an amazing article. This post was very valuable, I really respect you for this nice post, Helped me a bunch. Thanks Again.

Leave a Reply

Your email address will not be published. Required fields are marked *