Saturday, April 30, 2016

Very important CakePHP Descriptive Questions with answers

Posted by Tech Talim

 

1. What is CakePHP? Why use it?

Ans: CakePHP is a free, open-source, rapid development framework for PHP. It’s a foundational structure for programmers to create web applications. Our primary goal is to enable you to work in a structured and rapid manner–without loss of flexibility.
2.  What are the features of Cake PHP?
§  Active, friendly Official CakePHP discussion group
§  Flexible licensing
§  Compatible with versions PHP 5.2.8 and greater
§  Integrated CRUD for database interaction
§  Application scaffolding
§  Code generation
§  MVC architecture
3. What is Model?
The Model layer represents the part of your application that implements the business logic. It is responsible for retrieving data and converting it into meaningful concepts for your application

4. What is View?
The View renders a presentation of modeled data. Being separated from the Model objects, it is responsible for using the information it has available to produce any presentational interface your application might need

5. What is control layer?
The Controller layer handles requests from users. It is responsible for rendering a response with the aid of both the Model and the View layer.

6.  What is AppController class?
the AppController class is the parent class to all of your application’s controllers. AppController itself extends the Controller class included in the CakePHP core library.

7. What are the defferent part of the view layer in Cake PHP?
Ans: views: Views are the part of the page that is unique to the action being run. They form the meat of your application’s response.
elements: smaller, reusable bits of view code. Elements are usually rendered inside views. layouts: view files that contain presentational code that wraps many interfaces in your application. Most views are rendered inside a layout.
helpers: these classes encapsulate view logic that is needed in many places in the view layer

8. What is the purpose of $this->set()?
Function $this->set() in the controller is used to pass variables from the controller to the view

9. What is the name of Cakephp database configuration file name and its location?

Default file name is database.php.default.
Its located at "/app/config/database.php.default".To connect with database it should be renamed to database.php

10. What is the first file that gets loaded when you run a application using cakephp?can you change that file?

bootstrap.php
yes it can be changed.Either through index.php , or through .htaccess

11. What is the use of Security.salt and Security.cipherSeed in cakephp? How to change its default value?

- The Security.salt is used for generating hashes.we can change the default Security.salt value in /app/Config/core.php.  
- The Security.cipherseed is used for encrypt/decrypt strings.We can change the default Security.cipherSeed value by editing /app/Config/core.php.

12. 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.

13. What is a Component in cakephp?

Components are packages of logic that are shared between controllers. They are useful when a common logic or code is required between different controllers.

14. What are commonly used components of cakephp?

Security, Sessions,Access control lists,Emails,Cookies,Authentication,Request handling,Scaffolding

15. What is a Helper?

Helpers in CakePHP are associated with Presentation layers of application.
Helpers mainly contain presentational logic which is availabel to share between many views, elements, or layouts

16. What are commonly used helpers of cakephp?

FormHelper, HtmlHelper, JsHelper, CacheHelper, NumberHelper, Paginator

17. What is a Behavior?

Behaviors in CakePHP are associated with Models.
Behaviors are used to change the way models behaves and enforcing model to act as something else.

18. What is the difference between Component, Helper, Behavior?

Component is a Controller extension, Helpers are View extensions, Behavior is a Model Extension.

19. How to include helpers in controller ?

public $helpers = array(‘Form’, ‘Html’, ‘Js’, ‘Time’);

20. How to include components in controller ?

public $components = array(‘Emails’, ‘ImageUploader’, ‘Sms’);

21. How to write, read and delete the Session in cakephp?

$this->Session->write(‘Bird.Color’, ‘Black’);
$black = $this->Session->read(‘Bird.Color’);
$this->Session->delete(‘Bird’); 

22. What is the use of $this->set(compact());

Using $this->set(compact()) , we can pass multiple parameters to access into the view file.

23. Can you list some database related functions in cakephp?

find, findAll , findAllBy , findBy , findNeighbours and query.

24. How can you set custom page title for the static page?

To set a custom page title, copy-paste following code anywhere in your static page (.ctp) file:
$this->set("title_for_layout", "My page title");

25. How can we use ajax in cakephp?
Ans. By calling ajax helper and then using it in controller for rendering.

0 comments:

Post a Comment