Introduction to CodeIgniter in PHP
learn codeigniter for beginners
CodeIgniter is a lightweight, high-performance PHP framework designed to help developers build dynamic web applications quickly and efficiently. Known for its small footprint, simple architecture, and excellent speed, CodeIgniter remains a popular choice for both beginners and intermediate developers.
This tutorial introduces CodeIgniter, its features, installation steps, and how to build your first application using this powerful PHP framework.
CodeIgniter is an open-source PHP framework that uses the MVC (Model-View-Controller) architecture to separate the application logic from the user interface. It is ideal for developers who want a simple and efficient framework without unnecessary overhead.
Extremely fast and lightweight
Easy to learn and use
Minimal configuration
Excellent documentation
Built-in security features
Great for small-to-medium web applications
CodeIgniter follows the MVC pattern for structured and scalable development.
The full installation is less than 5 MB, making it one of the smallest PHP frameworks.
Includes protections against:
XSS
CSRF
SQL Injection
Input filtering
CodeIgniter provides helper functions for forms, URLs, strings, cookies, and more.
Supports multiple databases with Query Builder for simpler and safer queries.
Example:
$query = $this->db->get('users');
Provides detailed error reporting for faster development.
Simple and secure session control.
Follow these steps to get started.
Download from the official site:
https://codeigniter.com
Extract it into your web server directory (htdocs for XAMPP, www for WAMP).
Edit application/config/config.php:
$config['base_url'] = 'http://localhost/codeigniter/';
Open in browser:
http://localhost/codeigniter/
You should see the CodeIgniter welcome page.
application/ # Main application logic
system/ # Core CodeIgniter files
public/ # Public resources
controllers/ – Handles requests
models/ – Interacts with database
views/ – Displays data to users
Create file: application/controllers/Welcome.php
<?php
class Welcome extends CI_Controller {
public function index() {
echo "Welcome to CodeIgniter!";
}
}
Visit:
http://localhost/codeigniter/welcome
Create file: application/views/home.php
<h1>Hello from CodeIgniter!</h1>
Update controller:
public function home() {
$this->load->view('home');
}
Access:
http://localhost/codeigniter/welcome/home
Edit application/config/database.php:
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'mydb',
Controller:
public function users() {
$query = $this->db->get('users');
print_r($query->result());
}
Super-fast performance
Ideal for shared hosting
Small learning curve
Simple configuration and folder structure
Easy for beginners transitioning from core PHP
CodeIgniter remains a powerful PHP framework for developers who want simplicity, speed, and control. With its lightweight design, MVC architecture, built-in security features, and excellent documentation, it is an excellent choice for building small-to-medium web applications.
This introduction provides all the basics you need to begin your CodeIgniter journey—install it, configure it, and start building your first app today.