Cake PHP

Question : what is cakephp
Answer : 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.

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

Question. can you remember what is the directory structure when you download cakephp
1. app/
2. config/
3. controllers/
4. models/
5. plugins/
6. tmp/
7. vendors/
9. webroot/
10. cake/
11. config/
12. docs/
13. libs/
14. vendors/

Interviewer : what is the first file that gets loaded when you run a application using Cakephp, Me : can you change that file.
Answer : bootstrap.php , yes it can be changed , either through index.php , or through htaccess

Question : using cakephp, what all are drawbacks.
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 model,view,controller.
Answer : 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.

Question : what is the naming convention in cakephp
Answer : 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

Question : what is a component,helper and why are they used, is there other way we can do same thing, what is better.
Answer :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.

Question : how do you proceed when you have to use cakephp for any application.
Answer : 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

Question : what is the first function that gets loaded from a controller.
Ans : index

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

Question : how can we use ajax in cakephp.
Answer : by calling ajax helper and then using it in controller for rendering.

Question : if you have to validate a registration module for a user, what all can be possible ways , which one is the best.
Answer : can be done on submission in controller, or using javascript/ajax while user is still filling the data. second option is better.

Question : can you list some database related functions in cakephp.
Answer : find, findAll , findAllBy , findBy , findNeighbours , query

Question : how canInterviewer : how can you include a javascript menu throughout the site. give steps.
Answer : By adding the javascript files in webroot and call them in default views if needed everywhere or just in the related veiws.

Question : how can you make urls search engine friendly while using cakephp
Answer : it is an automatic task that is done by cakephp.

Question : do you prefer to use cakephp,yes then why ? no then why not.
Answer : 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 prefered for large systems, “simplicity” is the most important factor. you include a javascript menu throughout the site. give steps.

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

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

Question : what is the name of Cake’s database configuration file?
Answer: 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

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

Question : What is default function for a controller?
Answer: index() function

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

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

Leave a Reply