Sunday, 21 April 2013

Cakephp Interview Questions and Answers

Question: What is  cakephp?.
Answer: 
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
Answer: http://example.com/controller/action/param1/param2/param3

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
    Caching
    scaffolding




    Thursday, 11 April 2013

    Virtual Host Setup In Window System

    How to set up virtual host?



    Suppose,
    http://localhost will access to all the projects in the file,
    http://zf11.localhost will access to only one project and also set the document_path upto that's public folder

    Please take the backup of files, before alter to avoid any issue further.


    Do the Following simple steps,

    1)  Tell the system, what to do when called http://zf11.localhost
    FilePath: C:\Windows\System32\drivers\etc\hosts
    Add the Following, in above file
    127.0.0.1   localhost
    127.0.0.1   zf11.localhost

    2) Tell the apache, to include extra file
    FilePath: C:\wamp\bin\apache\Apache2.2.17\conf\http.conf
    Uncomment the following line
    Include conf/extra/httpd-vhosts.conf

    3) Tell the apache, what to do when request come from http://zf11.localhost
    FilePath: C:\wamp\bin\apache\Apache2.2.17\conf\extra\conf\extra\httpd-vhosts.conf
    Add the following line,  in the end

    <VirtualHost *:80>
        DocumentRoot "C:/wamp/www/zf1_11/public_html"
        ServerName zf11.localhost
        <Directory "C:/wamp/www/zf1_11/public_html">
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>








    http://www.kristengrote.com/blog/articles/how-to-set-up-virtual-hosts-using-wamp
    http://forum.wampserver.com/read.php?2,111881