Sunday 8 September 2013

Codeigniter Interview questions and answers part2

5. Explain Codeigniter File Structure.

When you download Codeigniter you will see the following folder structure :-•    application
o    cache
o    Config
o    Controllers
o    core
o    errors
o    helpers
o    hooks
o    language
o    libraries
o    logs
o    models
o    thirdparty
o    views


•    system
o    core
o    database
o    fonts
o    helpers
o    language
o    libraries


6. Explain Application Flow Chart in codeigniter.

Application flow chart from Codeigniter documentaion
1. The index.php serves as the front controller, initializing the base resources needed to run CodeIgniter.
2. The Router examines the HTTP request to determine what should be done with it.
3. If a cache file exists, it is sent directly to the browser, bypassing the normal system execution.
4. Security. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security.
5. The Controller loads the model, core libraries, helpers, and any other resources needed to process the specific request.
6. The finalized View is rendered then sent to the web browser to be seen. If caching is enabled, the view is cached first so that on subsequent requests it can be served.


 7. Explain MVC in Codeigniter.

Model–View–Controller (MVC) is an architecture that separates the representation of information from the user’s interaction with it.




cakephp mvc

Controller:- The Controller serves as an intermediary between the Model, the View. controller mediates input, converting it to commands for the model or view.
Model:-The Model represents your data structures. Typically your model classes will contain functions that help you retrieve, insert, and update information in your database.The model consists of application data and business rules.
View:-The View is the information that is being presented to a user. A View will normally be a web page.A view can be any output representation of data.
For more detail understanding MVC please read this article What is MVC(Model-View-Controller) Architecture.


8. What are the hooks in codeigniter.

CodeIgniter’s Hooks feature provides a means to tap into and modify the inner workings of the framework without hacking the core files.How ever you like to cause some action to take place at a particular stage in the execution process.
he hooks feature can be globally enabled/disabled by setting the following item in the application/config/config.php file:
$config['enable_hooks'] = TRUE;
Hooks are defined in application/config/hooks.php file.For example
view source
print?
1    $hook['pre_controller'] = array(
2    'class'    => 'MyClass',
3    'function' => 'Myfunction',
4    'filename' => 'Myclass.php',
5    'filepath' => 'hooks',
6    'params'   => array('test', 'test1', 'webs')
7    );


9. How you will add or load an model in codeigniter.

Models will typically be loaded and called from within your controller functions. To load a model you will use the following function:
view source
print?
1    $this->load->model('Model_name');

 
10. What are the helpers in codeigniter.

Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category.There are URL Helpers, that assist in creating links, there are Form Helpers that help you create form elements, Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, File Helpers help you deal with files, etc.
Loading a helper file is quite simple using the following function:
view source
print?
1    $this->load->helper('name');

4 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More