CodeIgniter Project Structure
⏱ 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
1. 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
2. public/ (Web Root)
-
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)
-
Cache
-
Logs
-
File uploads
-
Must have write permissions
5. env / .env
Environment configuration:
6. spark
Command-line tool for:
-
Creating controllers/models
-
Running migrations
-
Starting server
Example:
7. composer.json
-
Dependency management
-
Autoloading
CodeIgniter 3 Structure (Quick Comparison)
Key Differences: CI3 vs CI4
| Feature | CI3 | CI4 |
|---|---|---|
| PHP Version | 5.6+ | 7.4+ |
| Folder Structure | Simple | Modular |
| Namespaces | ❌ | ✅ |
| CLI Tool | ❌ | ✅ (Spark) |
Summary
-
app/→ your application code -
public/→ web-accessible files -
system/→ framework core -
writable/→ cache, logs, uploads
Register Now
Share this Post
← Back to Tutorials