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.
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.
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.
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.
CodeIgniter 4
About Lesson

Firstly, create a common file in the view folder. In this example, I have created a file name template.php in the /app/Views/ innerpages directory.

File structure:

	+ innerpages
		- footer.php
		- header.php
		- template.php
	- home.php

	- Home.php

Goto – template.php in Views


	echo view('innerpages/header.php');
	echo view($main_content);
	echo view('innerpages/footer.php');


In the above example, $main_content is a dynamic view for each page.

Goto – header.php in Views

<!DOCTYPE html>
<title><?php echo $title; ?></title>

Goto – footer.php in Views

<h1><?php $heading; ?></h1>


Goto – Home.php in Controllers

namespace App\Controllers;
use App\Controllers\BaseController;

class Home extends BaseController {

	public function index() {
		$data = [];
		$data['title'] 		= 'Page Title';
		$data['heading']	= 'Welcome to'
		$data['main_content']	= 'home';	// page name
		echo view('innerpages/template', $data);


The $data[‘main_content’] = ‘home’; represents the home.php file of the Views directory, and it will be replaced by the $main_content variable in the template.php file.

Goto – home.php in Views

<h4> Welcome to Home </h4>