Course Content
Introduction to CodeIgniter 4
CodeIgniter is an Application Development Framework. CodeIgniter is a popular and powerful MVC (Model-View-Controller) framework that is used to develop web applications. It is a free and Open-source PHP framework.
0/5
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).
0/6
Sessions
The Session class allows you to maintain a user’s "state" and track their activity while they browse your site.
0/1
URI Routing
There is a one-to-one relationship between a URL string and its corresponding controller class/method.
0/2
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.
0/5
Spreadsheet
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.
0/1
CodeIgniter 4
About Lesson

What is a Controller?

Controller receives the user input 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.

Controller Example – CodeIgniter 3

<?php 
class Home extends CI_Controller {
	
	public function index() {
		echo "Welcome to CodeIgniter 3";
	}

}
?>

Run in Browser:

http://localhost/project/index.php/home/


Controller Example – CodeIgniter 4

<?php
namespace App\Controllers;		

class Home extends BaseController {
	
	public function index() {
		echo "Welcome to CodeIgniter 4";
	}

}
?>

Run the following command in cmd/terminal from the project’s root directory:

> php spark serve
    http://localhost:8080

Run in Browser:

http://localhost:8080/index.php/Home/index

In the above example, Home.php is a default controller. You can alter the default namespace, controller, and method from /app/Config/Routes.php.