Below is a clear explanation of the CodeIgniter project structure, focusing on CodeIgniter 4 (with a short note on CI3 at the end).
app/ (Main Application Folder)This is where you write most of your code.
Controllers/Handles user requests and application flow.
Models/Manages database interactions.
Views/Contains UI files (HTML, CSS, JS).
Config/Application configuration files:
App.php → baseURL, app name
Database.php → database settings
Routes.php → URL routing
Database/Database-related files:
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
public/ (Web Root)
Entry point of the application
CSS, JS, images go inside assets/
system/ (Core Framework)Contains CodeIgniter core files
❌ Do NOT modify
writable/ (Writable Directory)
Cache
Logs
File uploads
Must have write permissions
env / .envEnvironment configuration:
sparkCommand-line tool for:
Creating controllers/models
Running migrations
Starting server
Example:
composer.jsonDependency management
Autoloading
| Feature | CI3 | CI4 |
|---|---|---|
| PHP Version | 5.6+ | 7.4+ |
| Folder Structure | Simple | Modular |
| Namespaces | ❌ | ✅ |
| CLI Tool | ❌ | ✅ (Spark) |
app/ → your application code
public/ → web-accessible files
system/ → framework core
writable/ → cache, logs, uploads
Take quizzes related to this topic and see where you stand!
Start Quiz Now