CodeIgniter Folder, File & Directory Structure
โก Smart Summary
CodeIgniter organizes a PHP project into predictable folders for application logic, framework system files, composer vendor packages, and a single entry script, so beginners can locate code quickly and intermediate developers can scale a clean MVC structure.

Understanding the file structure in CodeIgniter is essential before you build any real application. A predictable layout helps you locate controllers, models, and views quickly, debug routing issues, and onboard new team members faster. This tutorial covers the classic CodeIgniter 3 structure that is still widely deployed, and also clarifies the key differences you will encounter in CodeIgniter 4.x, which introduces app/, public/, and writable/ as separate top-level folders.
What Is the CodeIgniter File and Directory Structure?
The CodeIgniter file structure is the default arrangement of folders and PHP files that the framework ships with after you download or install it. It separates your application logic from the framework core, keeps composer dependencies isolated, and exposes a single entry point through index.php. The following image shows the file structure in CodeIgniter:
Here is a simplified directory tree for a fresh CodeIgniter 3 installation:
// CodeIgniter 3 root layout project-root/ โโโ application/ โโโ system/ โโโ user_guide/ โโโ vendor/ โโโ composer.json โโโ composer.lock โโโ index.php
Top-Level Folders Explained
Let us now look at the above files in CodeIgniter Structure:
- application โ this is the directory that will contain your application logic. All of your application code will be contained in this directory.
- system โ this folder contains the framework core files. It is not advised to make changes in this directory or put your own application code into this directory.
- user_guide โ this directory contains the user manual for CodeIgniter.
- vendor โ this directory contains composer packages source code. The other files related to this directory are composer.json and composer.lock.
- index.php โ this is the entry point into the application.
CodeIgniter Application Subdirectories
Let us now look at the directories in more detail. As mentioned, the application directory contains your project code. In this section, we will look at the internal subdirectories in the CodeIgniter directory structure:
- cache โ stores cached files generated by the output and database caching libraries.
- config โ keeps configuration files such as database.php, routes.php, and autoload.php.
- controllers โ all application controllers are defined here and map URL segments to actions.
- core โ contains custom core classes that extend system files. For example, if you create a base controller that other controllers should extend, you would place it in this directory.
- helpers โ this directory of the CodeIgniter folder structure is used for user-defined helper functions.
- hooks โ used for custom hooks in the CI folder structure that fire during the framework execution cycle.
- language โ used to store language files for applications that use more than one language.
- libraries โ used to store custom created libraries.
- logs โ application log files are kept in this directory.
- models โ all application models should be defined in this directory.
- third_party โ this is used for custom packages that you or other developers have created.
- views โ application views go into this directory.
Here is an example of the application subdirectory tree:
// application/ subdirectories application/ โโโ cache/ โโโ config/ โโโ controllers/ โโโ core/ โโโ helpers/ โโโ hooks/ โโโ language/ โโโ libraries/ โโโ logs/ โโโ models/ โโโ third_party/ โโโ views/
CodeIgniter System Subdirectories
Let us now look at system subdirectories in the CI file structure. Remember this is where the framework source code resides, therefore do not make any changes to the files in this directory.
- core โ this is like the heart of the CodeIgniter Framework. All of the core files that make up the framework are located here. If you would like to extend the functionality of the core file, then you need to create a custom core file in the application directory. After that, you can override or add new behavior that you wish. You should never make changes directly in here.
- database โ database drivers, cache, and other files needed for database operations are provided in here.
- fonts โ as the name suggests, this directory contains fonts and information relating to fonts.
- helpers โ this directory in the CodeIgniter structure folder contains helper functions that come out of the box.
- language โ contains language files that are used by the framework.
- libraries โ contains the source files for the various libraries that come with CodeIgniter out of the box.
The system folder layout looks like this:
// system/ subdirectories system/ โโโ core/ โโโ database/ โโโ fonts/ โโโ helpers/ โโโ language/ โโโ libraries/
CodeIgniter user_guide Directory
This directory serves as a reference guide for when you want to understand the CodeIgniter API. You should not upload this directory when deploying your application to production, as it adds size and exposes documentation that has no place on a live server.
CodeIgniter Vendor Directory
This directory contains source files for packages that you install via composer. The files in this directory should be left as they are and no changes should be made to them. Unlike the user_guide directory, this directory should be uploaded if you are using composer packages in your application.
index.php File
The index.php file in the CodeIgniter file structure contains the bootstrap code that defines environment, paths, and error reporting before handing control to the framework. This file is located in the root directory and acts as the front controller for every incoming HTTP request.
How CodeIgniter 4 Changes the Structure
CodeIgniter 4.x re-organized the layout to improve security and PSR-4 autoloading. Instead of a single application folder, you now see three top-level folders that separate concerns more strictly:
- app/ โ equivalent to the older application/ folder, holding Controllers, Models, Views, Config, Filters, and Libraries.
- public/ โ the only web-exposed folder, containing index.php and your CSS, JS, and image assets.
- writable/ โ stores cache, logs, sessions, and uploads that the framework needs to write at runtime.
- system/ โ still holds the framework core, namespaced under CodeIgniter\.
- vendor/ โ composer packages, identical in role to CI 3.
// CodeIgniter 4 root layout project-root/ โโโ app/ โโโ public/ โโโ writable/ โโโ system/ โโโ vendor/ โโโ tests/ โโโ composer.json โโโ env โโโ spark
If you are starting a new project today, CodeIgniter 4 is the recommended version. If you are maintaining an older codebase, the CI 3 structure described above will match what you see on disk.
Working With the CodeIgniter Structure Day-to-Day
Once you know where each folder lives, common tasks become straightforward. Create a new controller under application/controllers/ (or app/Controllers/ in CI 4), match it to a route in config/routes.php, build a model under models/, and render output from a view file in views/. Keep configuration in config/, drop reusable code into helpers/ or libraries/, and let composer manage everything inside vendor/. Stick to this discipline and your project will remain easy to navigate even as it grows.
