Cake Php

Q1 : What is cakephp?
A : Cakephp is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. It uses commonly known design patterns like MVC. It also reduces development costs and helps developers write less code.

Q2: What is the Directory structure when you download cakephp?
* app/
o config/
o controllers/
o models/
o plugins/
o tmp/
o vendors/
o views/
o webroot/
* cake/
o config/
o docs/
o libs/
* vendors/

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

Q4 : What is model,view,controller.
A : Model–view–controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other.
Model represents the information (the data) of the application;
View corresponds to elements of the user interface such as text, checkbox items, and so forth;
Controller manages the communication of data and the business rules used to manipulate the data to and from the model.

Q5 : What are the naming conventions in cakephp?
A : 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

Q6 : What is a component, helper and why are they used?
A: A component is an independent piece of code written for specific task that can be used by calling in controllers (example : email component),
Helper is used for helping cakephp in rendering the data to be shown to user with views, these only adds to modularity in code otherwise same coding can be implemented in conrollers.

Q7 : What is the first function that gets loaded from a controller?
A : index();

Q8 : What is habtm?
A : has and belongs to many is a kind of associations that can be defined in models for retrieving associated data across different entities.

Q9 : How can we use ajax in cakephp?
A : by calling ajax helper and then using it in controller for rendering.

Q10 : List some database related functions in cakephp.?
A: find, findAll , findAllBy , findBy , findNeighbours

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

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

Q13: What are 3 important parts of MVC?
A: The Model represents the application data
The View renders a presentation of model data
The Controller handles and routes requests made by the client

Q14 : Features of Cake php?
A: Compatible with versions 4 and 5 of PHP
MVC architecture
Built-in validations
Caching and scaffolding
– Application scaffolding is a technique that allows a developer to define and create a basic application that can create, retrieve, update and delete objects. Scaffolding in CakePHP also allows developers to define how objects are related to each other, and to create and break those links.

Q15 : What is the name of Cake’s database configuration file?
A: By default it is database.php.default, you can find it in /app/config/database.php.default
for connecting to database, it should be renamed to database.php

Q16 : What are controllers?
A: 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.

Q17 : What is default function for a controller?
A: index();

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

Q19 : What are commonly used components of cakephp?
1. Security
2. Sessions
3. Access control lists
4. Emails
5. Cookies
6. Authentication
7. Request handling

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

Q21: What is HABTM.
A: 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.

Q22: How cakephp URL looks in address bar?
A: http://example.com/controller/action/param1/param2/param3

Q23 : Why cakephp have two vendor folder?
A: There is two vendor folder, one folder in root and another is in “app” 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.

Q24: What is the role of dispatcher?
A: Dispatcher converts Requests into controller actions. It uses the dispatched Request to locate and load the correct controller. If found, the requested action is called on the controller.

Q25: How requests handled by CakePhp?

Q26: What are plugins? Where they are located?

Q27: Which function is executed before every action in controller?
A: beforeFilter()

Q28: How to write, read & delete the Session in cakephp??
A: $this->Session->write(‘UserName’, ‘Jon’);
$black = $this->Session->read(‘UserName’);
$this->Session->delete(‘UserName’);