An
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 packagesapt-get remove php
This command removes any existing PHP packages installed on your system.
Upgrade existing packages
# Upgrade existing packagesapt-get upgrade
This command upgrades the installed packages to their latest versions.
Install pending dependencies and fix broken packages
# Install pending dependencies and fix broken packagesapt-get install -f
This command installs any pending dependencies required by installed packages and fixes broken packages on your system.
Install PHP
# Install PHPapt-get install php
This command installs PHP on your system.
Verify PHP installation
# Verify PHP installationphp -v
This command displays the PHP version installed on your system to verify the installation.
Installing CodeIgniter
# Manually download and extract CodeIgniter 4curl -LO https://github.com/codeigniter4/framework/archive/v4.3.6.zipunzip v4.3.6.ziprm v4.3.6.zipmv framework-4.3.6 codeigniter4
This command manually downloads the CodeIgniter 4 from GitHub.
Install Composer
# Install Composermkdir composercd composercurl -sS https://getcomposer.org/installer | php -- --install-dir=./ --filename=composer#Navigate to your project's CodeIgniter directory:cd ..#installationphp composer/composer install
These commands download and install Composer on your system. Composer is a dependency management tool for PHP.
Verify Composer installation
# Verify Composer installationcomposer -v
This command displays the Composer version to verify the installation.
Start the development server
#strating the server./spark serve
This command starts with the built-in development server provided by CodeIgniter. It allows you to run and test your CodeIgniter application locally.
The script contains the required instructions for the setup.
#!/bin/bash# Script to install PHP and Composer# Update package listsapt-get update# Install required packagesapt-get install -y zip unzip git# Remove existing PHP packagesapt-get remove -y php# Upgrade existing packagesapt-get upgrade -y# Install pending dependencies and fix broken packagesapt-get install -f -y# Install PHPapt-get install -y php# Verify PHP installationphp -v# Manually download and extract CodeIgniter 4curl -LO https://github.com/codeigniter4/framework/archive/v4.3.6.zipunzip v4.3.6.ziprm v4.3.6.zipmv framework-4.3.6 codeigniter4# Install Composermkdir composercd composercurl -sS https://getcomposer.org/installer | php -- --install-dir=./ --filename=composer#Navigate to your project's CodeIgniter directory:cd ..#installationphp composer/composer install# Verify Composer installationcomposer -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