Cake PHP interview questions

Cake PHP interview questions

What is cakePHP ?
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, ORM within the convention over configuration paradigm, It also reduces development costs and helps developers write less code.

Why cakephp, and why not any other framework ?
It has been four years in the market with strong support in the form of online communities and documentation, it supports PHP 4/5 , sometimes it becomes mandatory to support php4 because of client’s limitation in support php5, there cakephp helps.

Can you remember 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/

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

What is meant by MVC?
1: Model view controller, it is a software architecture, used to isolate business logic from presentation logic. cakephp is based on mvc pattern.

2: 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. In MVC, the model represents the information (the data) of the application; the view corresponds to elements of the user interface such as text, checkbox items, and so forth; and the controller manages the communication of data and the business rules used to manipulate the data to and from the model.

What are 3 important parts of MVC?

  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

List some of the features in Cake PHP.

  1. Compatible with versions 4 and 5 of PHP
  2. MVC architecture
  3. Built-in validations
  4. Caching
  5. Scaffolding

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

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

What is the default function for a controller?
Index () function

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

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

Using cakephp, what all are drawbacks.
The learning curve, and it loads the full application before it starts your task. It’s not recommended for small projects because of its resource heavy structure.

What is the naming convention in cakephp ?
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, associations should use the ModelName, and the order should match the order of the foreignKeys: var $belongsTo = ‘User’; , foreign keys should always be: table_name_in_singular_form_id: user_id (foreign key) → users (table) , many-to-many join tables should be named: alphabetically_first_table_plural_alphabetically_second_table_plural: tags_users , columns in many-to-many join tables should be named like other foreign keys: tag_id and user_id , columns named “created” and “modified” will automatically be populated correctly

What is a component, helper and why are they used, is there another way we can do the same thing, what is better.
A component is an independent piece of code written for specific tasks 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 controllers.

How do you proceed when you have to use cakephp for any application.
Take the framework either from cake site or if you have changed according to your needs start from there. Proceed with basic software Engg. Concepts as requirement gathering etc.

What is habtm ?

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

How can we use Ajax in cakephp.
By calling Ajax helper and then using it in the controller for rendering.

If you have to validate a registration module for a user, what all can be possible ways , which one is the best.
Can be done in submission in the controller, or using javascript/Ajax while the user is still filling the data. The second option is better.

Can you list some database related functions in cakephp.
Find, findAll , findAllBy , findBy , findNeighbours , query

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

How can you make urls search engine friendly while using cakephp
It is an automatic task that is done by cakephp.

Do you prefer to use cakephp, yes then why ? No then why not ?
Its a wide question and the answer would depend upon the kind of application for which it is to be decided, if its a basic cms I would prefer to have Joomla. But yes cakephp is preferred for large systems, “simplicity” is the most important factor.

Be the first to comment “Cake PHP interview questions”

Time limit is exhausted. Please reload CAPTCHA.