Wednesday, October 27, 2010

cakephp interview questions

1. what is cakephp ?
Ans :- Cakephp is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. it uses commonly known architectural design patterns like MVC,ORM within the convention over configuration paradigm, It also reduces development costs and helps developers write less code.

2. what is the directory structure when you download cakephp ?
Ans :-
* 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/

3. what is the first file that gets loaded when you run a application using cakephp.,
Ans :- bootstrap.php , yes it can be changed , either through index.php , or through htaccess

4. what is model,view,controller.
Ans :- 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.

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

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


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


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

9: can you list some database related functions in cakephp.
Ans :- find, findAll , findAllBy , findBy , findNeighbours , query

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

4 comments: