How to install CodeIgniter

An MVCModel-View-Controller (MVC) framework is an architectural pattern that separates an application into three main logical components Model, View, and Controller.-based, lightweight PHP framework is called CodeIgniter. Offering a compact footprint, simple syntax, and a wide range of libraries makes developing online applications easier. CodeIgniter's convention over the configuration approach supports clean code and quick development.

Installation and setup guide

These steps must be followed to install and set up the CodeIgniter environment.

  • Open the terminal.

  • Navigate to the directory where you want the installation to begin.

  • Update pack lists

This command updates the package lists on your system, ensuring you have the latest information about available packages.

  • Remove existing PHP packages

# Remove existing PHP packages
apt-get remove php
Removing if any older version of php exists

This command removes any existing PHP packages installed on your system.

  • Upgrade existing packages

# Upgrade existing packages
apt-get upgrade
Upgrading the existing packages

This command upgrades the installed packages to their latest versions.

  • Install pending dependencies and fix broken packages

# Install pending dependencies and fix broken packages
apt-get install -f
Installing dependencies with broken packages fixed

This command installs any pending dependencies required by installed packages and fixes broken packages on your system.

  • Install PHP

# Install PHP
apt-get install php
Installing php

This command installs PHP on your system.

  • Verify PHP installation

# Verify PHP installation
php -v
Verifying version installed

This command displays the PHP version installed on your system to verify the installation.

  • Installing CodeIgniter

# Manually download and extract CodeIgniter 4
curl -LO https://github.com/codeigniter4/framework/archive/v4.3.6.zip
unzip v4.3.6.zip
rm v4.3.6.zip
mv framework-4.3.6 codeigniter4
Downloading and extracting CoddeIgniter4 from github manually

This command manually downloads the CodeIgniter 4 from GitHub.

  • Install Composer

# Install Composer
mkdir composer
cd composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=./ --filename=composer
#Navigate to your project's CodeIgniter directory:
cd ..
#installation
php composer/composer install
Installing composer

These commands download and install Composer on your system. Composer is a dependency management tool for PHP.

  • Verify Composer installation

# Verify Composer installation
composer -v
Verifying version of composer

This command displays the Composer version to verify the installation.

  • Start the development server

#strating the server
./spark serve
Starting the server

This command starts with the built-in development server provided by CodeIgniter. It allows you to run and test your CodeIgniter application locally.

Running the CodeIgniter application

The script contains the required instructions for the setup.

#!/bin/bash
# Script to install PHP and Composer
# Update package lists
apt-get update
# Install required packages
apt-get install -y zip unzip git
# Remove existing PHP packages
apt-get remove -y php
# Upgrade existing packages
apt-get upgrade -y
# Install pending dependencies and fix broken packages
apt-get install -f -y
# Install PHP
apt-get install -y php
# Verify PHP installation
php -v
# Manually download and extract CodeIgniter 4
curl -LO https://github.com/codeigniter4/framework/archive/v4.3.6.zip
unzip v4.3.6.zip
rm v4.3.6.zip
mv framework-4.3.6 codeigniter4
# Install Composer
mkdir composer
cd composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=./ --filename=composer
#Navigate to your project's CodeIgniter directory:
cd ..
#installation
php composer/composer install
# Verify Composer installation
composer -v
# Start the development server
./spark serve

Each step in the script ensures that PHP, Composer, and CodeIgniter are correctly installed and then starts the development server.

Run these instructions in your terminal, and you can view the application running on this "http://localhost:8080"

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved