Programming Codeigniter CodeIgniter Introduction, features and How it works

CodeIgniter Introduction, features and How it works

CodeIgniter Introduction, features and working

What is CodeIgniter?

First of all, let’s discuss what CodeIgniter is and why we should use it.

CodeIgniter is an Application Development Framework for building PHP powered web sites rapidly.

As you already know that a collection of re-usable classes or libraries is called a framework. Similarly, CodeIgniter is also a PHP framework. It takes a minimal amount of storage,  particularly in 3 to 4 MB. Secondly, it is way too easy to understand for beginners As the programs are too accurate and easy to understand while writing codes. The most important part that makes it easier is the documentation in which you will find the answer to almost every query you can have related to CodeIgniter. Such as how to call a function of a class or how to connect to a database etc.

It provides a rich set of libraries for the commonly needed tasks. Like connecting to the database and performing operations Like sending emails, uploading files, managing sessions, etc. It enables developers to complete projects faster than it can be done with scratch coding. Also, it provides a simple interface and logical structure to access these libraries with ease.

As CodeIgniter is based on MVC Structure:

Model: The backend structure of a website like “database”.

View: The front-end interface of the website like HTML.

Controller: It controls the communication between a model and a view.

How to Install Codeigniter

You can install the Codeigniter PHP Framework from the link below:

Once you download it, extract the files from the zip folder and copy the contents and then paste it to a new folder under htdocs folder of your XAMPP server. Along with this, I would recommend an advanced editor like Sublime, Aptana or PhpStorm.

Codeigniter Directory Structure

Now, open this folder in your script editor and then you will see some important folders like:

User Guide: It is nothing but an offline copy of Documentation that you will find on the official website.

The most important folder that you will deal with is:

Application: In this folder you different files like cache, config, models, views, and controllers, etc.

For example, in the config folder, you will find a class file called “Autoload.php”. Now remember, in CodeIgniter, whatever the library you are going to use, you need to load it. And sometimes there are some libraries that you will use so frequently. In that case, you will call those libraries in Autoload so they will be loaded automatically.

The second file is “Database.php” where you will mention which database to be used because almost every application today connects to a database.

Next most important file which will be used is “Route.php” in which you will define a default controller which will determine which controller will be hit while accessing the URL. By default, it is “Index.php”.

To know more about this, stay tuned until we upload next articles on this and please leave us a query if you have any and we would love to answer that as soon as possible.

CodeIgniter Features

Let’s see some of the features that make CodeIgniter great. The following list is not exhaustive but gives you an idea of what to expect when working with this framework.

#1 Framework with a small footprint:

The complete source code for CodeIgniter-3.1.10 is approx. 1.85MB. However, when we download it, a user guide section also comes with it which occupies around 900Kb.

The deployment and updating of CodeIgniter are also very handy.

#2 CodeIgniter has blazing fast speed:

In this fast-paced world, users want applications to load very fast. Almost all the modern frameworks today have a very efficient load time. The applications take less than one second to load after completion of installation.  It takes less than 50ms to load after its successful installation.

#3 Nearly zero configurations:

If you are a beginner to MVC frameworks, then CodeIgniter is going to be your best choice. It needs nearly no configuration (just a few and very basic ones only) to make it work.

#4 Loosely coupled:

CodeIgniter does not rely much on other components as the built-in features are designed to work independently.  Also, it does not require you to adhere to restrictive coding rules.

#5 Based on MVC Architecture:

CodeIgniter is based on the Model-View-Controller architecture. Model-View-Controller keeps the database, business logic, and presentation (views) separately.

#6 Excellent documentation of CodeIgniter:

This framework has the best document in comparison with all other modern frameworks. Additionally, there are a lot of books and tutorials available and are really nice. There are also many forums that solve your queries. Overall, if you are using CodeIgniter, there is a big community to help you out in any challenge and circumstance you will face.

#7 Extendibility:

CodeIgniter is bundled with some out of the box libraries and helpers. If there is something that you need and is not present, don’t worry.  You can create your own libraries, helpers, packages, etc. very easy to get the features you want. Furthermore, you can implement existing features the way you want by overwriting them.

#9 Easy to learn:

Anybody who is familiar with PHP can very easily master this framework, as it is not at all complicated and easy to learn. Either you are a student, or a newbie developer, you can start developing professional applications very quickly using CodeIgniter.

How CodeIgniter works

As I have explained above, CodeIgniter on MVC (Model View Controller) Pattern. As the user requests for any resources from the CodeIgniter website, firstly index.php handle that request. As index.php acts as the frontend controller and initializes the base resources to run the framework.

Then comes the routing part. If any routes are overwritten (will be explained later) then are considered at this point.

After this point the framework checks for the caching. If present the user is provided the cached response, without executing internal code and database queries. This feature enables for faster response.

If caching is not present/ enabled then user data and HTTP requests are filtered by Codeigniter to filter for security purpose.

Then reaches the controller and required models, helpers, libraries and other plugins and scripts are executed to get the result.

This result is then finalized in the form of view which is the display part. That view is sent to the user as a response. In between (if caching is enabled) the view is stored in cached for handling to provide faster response similar request again without internal system execution.

I am providing an Application Flow Diagram to understand working easily.

Codeigniter application flow to show how Codeignitor works

One thought on “CodeIgniter Introduction, features and How it works

  1. Undeniably imagine that that you said. Your favorite reason seemed
    to be on the internet the simplest thing to be mindful of.
    I say to you, I definitely get irked at the same time as people consider
    concerns that they just don’t recognise about. You controlled to hit the nail upon the top and also outlined out the whole thing with no need side-effects ,
    people can take a signal. Will likely be again to get more.

Leave a Reply