When developing web applications, it is often found that people spend a good amount of time writing the same thing again and again. The user authentication, templating, database models, etc have to written every time you develop a new web application.
This calls for a solution where a framework is available and you don’t have to repeat the same thing continuously. CodeIgniter does the work for you. It is an open-source software used as a framework to develop dynamic websites and applications with PHP. However, this doesn’t mean that you will stop using PHP. CodeIgniter is just a container of plugins, libraries, helpers and other resources that supplement the complex functionality of PHP.
If you’re a CodeIgniter aspirant planning to sit for an interview, then we’ve listed few questions that have the high probability of being asked. So, delve straight into the questions give below and ace your CodeIgniter interview.
1. Explain what is CodeIgniter?
CodeIgniter is a PHP framework used for developing web applications and websites. It is based on MVC (Model View Control) pattern and is considered to be the one of the best frameworks in terms of speed. CodeIgniter aids your work by providing huge set of libraries, logical structure and simple interface which enables you to create projects faster than manually writing codes from scratch.
2. When was the first version of CodeIgniter realised? Name the current version.
Ans- The very first version of CodeIgniter was released on February 8, 2006. Its current development version 3.o dev, licensed with Open Software License, was released on October 20, 2011.
3. Brief about hooks in CodeIgniter.
ANS- The hook feature of CodeIgniter is used to alter the inner functionality of PHP framework. This modification is done keeping mind that no disturbance is done to the core files. In simpler terms, hook allows execution of scripts with specific path in the CodeIgniter execution process. Using hook feature will save your time from writing the code multiple times. It can be defined as
application/config/hooks.php file. For example,
‘class’ =>’MyClass’, ‘function’ =>’MyFunction’, ‘filepath’ =>’hooks’.
4. Enlist different types of hooks in CodeIgniter.
Ans- The different types of hook points in CodeIgniter are as follows-
post_controller_constructor
pre_controller
post_sytem
pre_system
cache_override
display_override
post_controller
$hook[‘pre_controller’] = array(‘class’ => ‘MyClass’,
‘function’ => ‘Myfunction’,‘filename’ => ‘Myclass.php’,‘filepath’ => ‘hooks’,‘params’ => array(‘param1’, ‘param2’, ‘param3’));
5. Enlist the prominent features of CodeIgniter?
ANS- The following are the features of CodeIgniter that makes it stand out from all other frameworks-
- It is a free, open-source PHP framework.
- Unlike other frameworks that require huge file libraries, CodeIgniter is a light weighted framework that requires only a few small libraries.
- It is fast as compared with any other frameworks of PHP.
- CodeIgniter is extensible which can be easily extended using class extensions, helpers or system hooks.
- It is based on MVC pattern and requires nearly zero configurations.
6. What are the CodeIgniter file structures?
Ans- The following are the folder structure that you’ll get when you download CodeIgniter-
- Application- helpers, hooks, language, library, cache, models, views, thirdparty, Controllers..
- System- core, database, fonts, language, libraries.
7. What is the default URL pattern used in CodeIgniter?
ANS- In default URL pattern, there are four main components in CodeIgniter. First we have the server name followed by the controller class name. Then, we have controller function name and at the end there are function parameters. We can access the CodeIgniter using the URL helper.
Syntax- http://servername/controllerName/controllerFunction/parameter1/parameter2.
8. Elaborate about MVC and helpers in CodeIgniter.
Ans-MVC- CodeIgniter is based on MVC pattern. It is an acronym for Model view Control. MVC seperates the application logic from presentation. Since the presentation is separated from PHP, MVC ensures that the web pages contain less scripting.
Helpers- Helpers are the bunch of functions in a particular category that aid you in your tasks. There are various types of helpers like URL helpers, form helpers, text helper, cookie helpers and file helper. Each of these types have a distinct set of functions.
9. How to use or add libraries in CodeIgniter?
Ans- In CodeIgniter, there are library directories that contain classes. These classes are known as libraries. In order to use one of the classes, we have to initialize it within a controller with the help of a following function-
$this->load->library(‘class name’);
10. How to set default time zone in CodeIgniter?
Ans- Add date_default_timezone_set(‘your timezone’); in index.php
CodeIgniter is the most sought-after framework of PHP when it comes to developing dynamic websites and web applications. Developers prefer it due to its speed. Cracking a CodeIgniter interview is not a cakewalk. So, the above questions have been curated keeping in mind the aspirants who are planning to ace the interview and win over their opponents. The answers to these questions are brief, crisp and up-to the mark.