Home »
PHP
What is PHP CODEIGNITER?
In this article, we will learn about "PHP CodeIgniter", what is it ? How it works? How to install it?
Submitted by Jyoti Singh, on January 27, 2018
Introduction
CodeIgniter is a PHP framework which is used to build a dynamic website using PHP (which is a server-side scripting language). CodeIgniter serves you a simple way to build your website.
Building a Website takes a lot of time as we have to write a lot of code again and again which is very hectic sometimes. CodeIgniter framework provides you a lot of functionality which reduces the amount of code as well as the time needed to build a website.
CodeIgniter comprises of libraries, interfaces, helpers, plug-ins and many other functionalities which makes your work easy and maintain a high performance. CodeIgniter supports PHP versions of 5.2.6 or higher. CodeIgniter is an open source framework. It’s a free, light-weighted toolkit which is easy to install and easy to use. In order to use CodeIgniter you need to know basic syntax of PHP and how it communicates with the database?
CodeIgniter follows MVC Pattern i.,e Model, View, Controller. Though it doesn’t force you to follow it,butit’s always good to use the MVC pattern as it is easy to understand the data flow.
A the controller is responsible for handling all the request that comes from the browser and returns the response to it.
Model is responsible for the database actions i.e, insert, delete, update, display all that takes place in the model. CodeIgniter provides a lot of query functions which don’t need to write the query, you can just use query functions.
The view is to display output or response in the browser or we can say that view is responsible for the User interface.
Now let’s understand how MVC work by this simple visual diagram.
Note: Browser request will first come to Controller and then the controller will load the appropriate view page according to the URL.
Installation
There are mainly two versions of Codeigniter are available one is Codeigniter 2.x and the second is a newer version which is Codeigniter 3.x.You can directly download CodeIgniter from its website, here, we have provided the URL to download the CodeIgniter from its website.
Click on this link to download Codeigniter: https://codeigniter.com/download
Step 1: Download CodeIgniter from the above link.
Step 2: Downloaded file will be a zip file, extract it to your wamp folder(if you are using wamp)/or in xampp folder in case of xampp.
Step 3: Now you will see a folder named as CodeIgniter, you can rename it or you can continue with the same name.Let’s suppose we have renamed it to demoCodeigniter.
Step 4: Inside the wamp/ xampp open demo CodeIgniter -àopen applications.Here, you will see many default folders which are provided by CodeIgniter like controllers, views, models and many more.
Step 5: To check if you have successfully install CodeIgniter, it’s time to run it.Open controller folder, here u will see a PHP file named as “Welcome” which includes an index function to load welcome message view. Inside your browser type this URL: "http://localhost/demoCodeigniter/index.php/Welcome/"
Note: In the URL, write your CodeIgniter folder name (my folder name is demoCodeigniter).
Step 6: If you see something like this, Voila! you have successfully installed your CodeIgniter.
Read: First Example based on PHP CodeIgniter MVC