CakePHP Interview Questions and Answers

02nd, January 2014 By

1. what is cakephp.

Cake php is open source framework.Its was written in PHP.This is the structure for creating web application.

2. When cakephp developed.

Cake php started at april 2005.when a Polish programmer Michal Tatarynowicz wrote a minimal version of a Rapid Application Framework in PHP, dubbing it Cake.Cake php version 1.0 released in May 2006.Now latest version released in cakphp is 2.3.4.

3. What is latest version of cake php and when released.

The current version of cake php is 2.3.4. Its release 28 April 2013.

4. Explain some features of cake php.

1. cake php based on MVC(Model view controller) architecture.

2.The cake php, Integrated CRUD for database interaction.

3. The cake php Compatible with versions PHP 4 , 5.2.8 and greater.

4. Cake php have built-in validation.

5. Cake php have Fast and flexible templating means good php syntax with helper.

6. The cake php have Flexible Caching.

7. Flexible ACL ,good Code generation ,Application scaffolding , Data Sanitization ,Localization and also Works from any web site directory.

8. Very friendly as developer work from model and controller without effect the views or designer will work on views without effect the developer work.

5. What is drawbacks of cake php.

1. Its not recommended for small projects because of its resource heavy structure.

2. learning curve.

3. The cake php loads full application before it starts your task.

6. What is directory structure of cake php.

When you download cake php you will see the following folder structure :-

  • app
    • config
    • controllers
    • libs
    • locale
    • models
    • plugins
    • tmp
    • vendors
    • views
    • webroot
  • cake
  • vendors
  • plugins
  • .htaccess
  • index.php
  • README

7. Explain MVC in cake php.

Model–View–Controller (MVC) is an architecture that separates the representation of information from the user’s interaction with it.

Controller:- The Controller serves as an intermediary between the Model, the View. controller mediates input, converting it to commands for the model or view.

Model:-The Model represents your data structures. Typically your model classes will contain functions that help you retrieve, insert, and update information in your database.The model consists of application data and business rules.

View:-The View is the information that is being presented to a user. A View will normally be a web page.A view can be any output representation of data.

For more detail understanding MVC please read this article What is MVC(Model-View-Controller) Architecture.

8. How can use ajax in cake php.

We can use ajax in cake php by calling ajax helper and then using it in controller for rendering.

9. Explain some database related functions in cake php.

find

find(‘all’)

find(‘first’)

findAllBy

findBy

10. What is the name of Cake php database configuration file.

The name of the database configuration file in cake php is database.php . Its find in :-

/app/config/database.php

When you download cake php by deafult its name is database.php.default , which have to rename to database.php

11. What is default function for a controller.

The default function for controller is index().

12. What is a Component in cakephp.The mostly used components of cakephp.

Components are packages of logic that are shared between controllers.The component are very useful when you want to use same functionality on different controller.

1. Sessions

2. Security

3. Emails

4. Cookies

5. Access control lists

6. Authentication

7. Request handling

8. Pagination

13. what is the first file loaded when you run a application using cakephp.

Its bootstrap.php , you can change it by index.php or through .htaccess .

14. What are the helper in cake php.

Helpers are the component-like classes for the presentation layer of your application. They contain presentational logic that is shared between many views, elements, or layouts.Some of core helper are:-

1. CacheHelper

2. FormHelper

3. HtmlHelper

4. SessionHelper

5. JsHelper

6. TimeHelper

7. RSS

15. Explain naming convention in cake php.

The naming convention in cake php like:-

Table names are plural and lowercased.The underlying tables for the above mentioned models would be people, big_people, and really_big_people, respectively.

Model names are singular and CamelCased.ModelName, model filenames are singular and underscored like model_name.php.Person, BigPerson, and ReallyBigPerson are all examples of conventional model names.

Controller classnames are plural, CamelCased, and end in Controller. PeopleController and LatestArticlesController are both examples of conventional controller names.

16. What is habtm in cake php.

The habtm(hasAndBelongsToMany) is a kind of associations that can be defined in models for retrieving associated data across different entities.

17. How can you include a JavaScript menu throughout the site.

we can include a JavaScript menu throughout site by adding the JavaScript files in webroot and call them in default views if needed everywhere or just in the related views.

18. What is Scaffolding in Cakephp.

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

19. What are associates and explain the four associates in cake php.

In CakePHP, the links between models are handled through associations.The four associates in cake php are:-

hasOne :- Have one to one relationship and a user have one profile.

hasMany :- Have one to many relationship and a user can have multiple recipes.

belongsTo :- Have many to one relationship and Many recipes belong to a user.

hasAndBelongsToMany(Habtm) :- Have many to many relationship and Recipes have, and belong to many ingredients.

20. The bindModel() and unbindModel() Model methods are used in cake php for?

To Create and destroy model associations on the fly.

21. If you have to validate a registration module for a user, what all can be possible ways , which one is the best.

This can be done on submission in controller, or using javascript/ajax while user is still filling the data. second option is better.

22. The method requestAction is used in cake php ?

The method requestAction are used in cake php for calls a controller’s action from any location and returns data from the action.

23. Which function is executed before every action in the controller.

beforeFilter

1 Comments on “CakePHP Interview Questions and Answers

  • Hi! I’m att work surfig around your blog from my new apple iphone!
    Just wanted to say I lobe reading through your blog and look forward to all your posts!
    Keep uup the superb work!

    Reply

Leave a Reply

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