Sunday 21 April 2013

Cakephp Interview Questions and Answers

Question: What is  cakephp?.
CakephpCakePHP  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: When CakePHP was developed?
April 2005

Question: What is current Stable version of cakePHP?
3.1.5 / 30 November 2015

Question: For cakPHP 3.1.5 installtion, what is minimum PHP Version required?
PHP 5.4

Question: What are are 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 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 Login

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

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: 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.
For Example
A product have one or more tags, and a tag may belongs to one or more product.

HABTM Relation

 * Post Model
 * @property Tag $Tag
class Post extends AppModel {

 * Display field
 * @var string
 public $displayField = 'name';

 * Validation rules
 * @var array
 public $validate = array( );

 * hasAndBelongsToMany associations
 * @var array
 public $hasAndBelongsToMany = array(
  'Tag' => array(
   'className' => 'Tag',
   'joinTable' => 'posts_tags',
   'foreignKey' => 'post_id',
   'associationForeignKey' => 'tag_id',
   'unique' => 'keepExisting',


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 : How cakephp URL looks in address bar

Question : Why cakephp have two vendor folder?
Answer: There is two vendor folder, one folder in root and another is in "app" folder

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

    Question : List some of the features in Cakephp
    Answer: Following are some feature of Cakephp.

    • Full support of (MVC)Model, View, Controller Architecture.
    • Scaffolding.
    • Very nice Code generation via Bake.
    • Helpers for HTML, Forms, Pagination, AJAX, Javascript, XML, RSS and more.
    • Access Control Lists and Authentication (ACL & Auth).
    • 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.
    • 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 application
    • Configure class to provide dynamic handling of configuration settings and App class to handle importing required classes.
    • Now Supports Unit Testing application.
    • Integration with Crusecontrol and Ant.

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