What is CodeIgniter? It is a very famous PHP Framework used in IT industry. CodeIgniter is based on MVC architecture. This is considered as a toolkit for all the PHP developers. And it consists with enhancement and reusability of the PHP codes as it is having many reusable components such as libraries, plugins and many other things.

What is MVC?

It simply means Model View Controller.

Model - Includes the logic such as database connectivity , algorithms.

View - This is the front end displayed for the user including UI with HTML pages.

Controller -  Gets the action request to load pages, gets data from model and passes them to the view.

for more information, visit this page.



How to start coding with CodeIgniter?

  • First you need to download CodeIgniter from their official web site. Link is here.
  • Then unzip it and place it in your root folder of XAMPP or WAMP. Rename this folder as you want. In my case I named it as CITEST.
  • Open the folder with a text editor; (Sublime is better) and look at the file structure. The sub folder called application includes 3 folders names as models, controllers and views. Those are the main items used when we start with CodeIgniter.

Getting Started...

First open the autoload.php file included in applications/config. This is the file that load some component automatically for our ease. When you open it, you will see there are code lines with with array function such as autoload packages, libraries, drivers, helpers and etc. You can include them at the relevant place when you are using those components. For now, keep it as the same.

Then open the database.php file included in the same folder. It contains the details of the database connection. At the end of the file, there are few lines to be configured according to your database connection. Create a database to connect with CodeIgniter. These are my information.


In my case database is "ci". Change the hostname and password as root or any other name given by you during your installation of WAMP or XAMMP. Give the database name also. Keep the other things without any change. Now, first step is completed!

Now find the Welcome.php file located in controllers sub folder. It is the default controller that loads when we start using CodeIgniter. It's content is shown below.


How do you get to know that CodeIgniter is working?

There are some thing to do for this part. You have to call the index function included in the Welcome controller. What does this index function do? It says to load the view called welcome_message. That is the front end output displayed to the user. Here, CI_Controller is the Parent Controller. Welcome controller will inherit the features of CI_Controller. Now go to the views sub folder and you will find the welcome_message.php file. The content in this view file should be loaded when we test CodeIgniter at first time.

Usage the URL

There's a way to call for the URLs to load files in CodeIgniter. Let's take a look.
I have included my CodeIgniter folder in a sub folder called PHPProjects in the root folder. So the calling URL path should be in this format.

   localhost/ SubRootFolder/CIFolder/index.php/ControllerName/FunctionName

According to my folder and file structure, I will use this path. Check with your structures.

   localhost/PHPProjects/CITEST/index.php/welcome/index

Since  we are going to load the default function, the final part of URL - index.php/welcome/index will be the same as my URL. 
If you have followed with my correctly, you will get a output like this after you entered the URL correctly in your browser. Now you will realize that the content of the welcome_message view file has been given as the output here.


Now you have a working setup of CodeIgniter! 
Try to configure this part and wait for the next part of this simple documentation. 
Good Luck!


0 Comments