CodeIgniter Project Structure

📘 CodeIgniter 👁 32 views 📅 Dec 22, 2025
⏱ Estimated reading time: 2 min

Below is a clear explanation of the CodeIgniter project structure, focusing on CodeIgniter 4 (with a short note on CI3 at the end).


CodeIgniter 4 Project Structure

codeigniter4/ │ ├── app/ ├── public/ ├── system/ ├── writable/ ├── env ├── spark └── composer.json

1. app/ (Main Application Folder)

This is where you write most of your code.

app/ ├── Config/ ├── Controllers/ ├── Models/ ├── Views/ ├── Database/ ├── Filters/ ├── Helpers/ ├── Language/ └── Libraries/

???? Controllers/

Handles user requests and application flow.

class Home extends BaseController { public function index() { return view('home'); } }

???? Models/

Manages database interactions.

class UserModel extends Model { protected $table = 'users'; }

???? Views/

Contains UI files (HTML, CSS, JS).

<h1>Welcome to CodeIgniter</h1>

???? Config/

Application configuration files:

  • App.php → baseURL, app name

  • Database.php → database settings

  • Routes.php → URL routing


???? Database/

Database-related files:

Database/ ├── Migrations/ ├── Seeds/ └── Factories/
  • Migrations → version control for database schema

  • Seeds → insert dummy data


???? Filters/

Middleware-like logic (auth, CSRF, etc.)


???? Helpers/

Reusable functions (form, URL, text helpers)


???? Language/

Multilingual support files


???? Libraries/

Custom libraries and classes


2. public/ (Web Root)

public/ ├── index.php ├── .htaccess └── assets/
  • Entry point of the application

  • CSS, JS, images go inside assets/


3. system/ (Core Framework)

  • Contains CodeIgniter core files

  • Do NOT modify


4. writable/ (Writable Directory)

writable/ ├── cache/ ├── logs/ ├── session/ └── uploads/
  • Cache

  • Logs

  • File uploads

  • Must have write permissions


5. env / .env

Environment configuration:

CI_ENVIRONMENT = development

6. spark

Command-line tool for:

  • Creating controllers/models

  • Running migrations

  • Starting server

Example:

php spark make:controller Home

7. composer.json

  • Dependency management

  • Autoloading


CodeIgniter 3 Structure (Quick Comparison)

application/ ├── controllers/ ├── models/ ├── views/ ├── config/ system/

Key Differences: CI3 vs CI4

FeatureCI3CI4
PHP Version5.6+7.4+
Folder StructureSimpleModular
Namespaces
CLI Tool✅ (Spark)

Summary

  • app/ → your application code

  • public/ → web-accessible files

  • system/ → framework core

  • writable/ → cache, logs, uploads


🔒 Some advanced sections are available for Registered Members
Register Now

Share this Post


← Back to Tutorials

Popular Competitive Exam Quizzes