Course Content
Introduction to CodeIgniter
CodeIgniter is a powerful PHP framework built for developers who need a simple and elegant toolkit to create full-featured web applications.
MVC (Model-View-Controller)
MVC stands for Model-View-Controller. MVC is an application design model consisting of three interconnected parts. They include the model (data), the view (user interface), and the controller (processes that handle input).
The Session class allows you to maintain a user’s "state" and track their activity while they browse your site.
URI Routing
There is a one-to-one relationship between a URL string and its corresponding controller class/method. The segments in a URI normally follow this pattern:
Forms and Input
Forms provide a way for users to interact with the application and submit data.
Composer is dependency manager in PHP. it allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
You can enable CSRF protection by modifying your application/config/config.php file
Working with Database
Like any other framework, we need to interact with the database very often and CodeIgniter makes this job easy for us. It provides a rich set of functionalities to interact with the database.
DataTables is a table enhancing plug-in for the jQuery Javascript library that helps in adding sorting, paging, and filtering abilities to plain HTML tables with minimal effort. The main goal is to enhance the accessibility of data in normal HTML tables.
PhpSpreadsheet is a PHP library for reading and writing spreadsheet files. Importing Excel and CSV into MySQL help to save the user time and avoid repetitive work.
Payment Gateway
Razorpay and PayTM Payment Gateway
WhatsApp Chatbot and Telegram Chatbot
CodeIgniter 3
About Lesson

The Controller receives the user input and validates it, and then passes the input to the Model. It performs interaction on the model objects.

It is a simple class file. The name of the class is associated with URI. The first letter of a class name must be capital.

For example, Welcome.php

class Welcome extends CI_Controller {
	public function index() {
		// write your code
		echo "Welcome to CodeIgniter";


The Welcome class extends an in-built class called CI_Controller. This class must be extended whenever you want to make your Controller class.


Calling a Controller

The above controller can be called by URI as follows −


In the above Welcome.php example index() is the method. If you run with only the class name in the URL by default the index() method will be executed. If you want to add another method then we have to create another function like the following example.

class Welcome extends CI_Controller {
	public function index() {
		// write your code
		echo "Welcome to CodeIgniter";

	public function about_us() {
		echo "";


To get the output of the second method using the URL is:

Run in URL:



How to set Default Controller in CodeIgniter?

To specify a default controller, open your application/config/routes.php file and set this variable:

$route['default_controller'] = welcome;

Here ‘welcome’ is the name of the controller class. If you now load your main index.php file without specifying any URI segments you’ll see a “Welcome to CodeIgniter” message by default.

How to pass URI Segments or parameters to the method in CodeIgniter

If a URI contains more than two segments they will be passed to your method as parameters.

For example,



http://localhost/blog		= base url	URI segment 0
Welcome				= Controller	URI segment 1
user_details			= Method	URI segment 2
Junaid				= Parameter1	URI segment 3
25				= Parameter2	URI segment 4
class Welcome extends CI_Controller {
	public function user_details($name, $age) {
		echo "My name is ".$name." and I am ".$age." years old.";




The name of the controller class must start with an uppercase letter.

Do not use the same name of the method as your parent class, as it will override the parent class’s functionality.