It is very important to understand the file structure in CodeIgniter if you want to develop applications successfully.
CodeIgniter File/Folder/Directory Structure
The following image shows the file structure in CodeIgniter
Let’s 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.
Let’s now look at the directories in more details
CondeIgniter Application Subdirectories
As we stated above, this directory contains the application code. In this section, we will look at the internal subdirectories in CodeIgniter directory structure:
- cache – stores cached files
- config – keeps configuration files
- controller – all application controllers are defined in this controller
- core – contains custom core classes that extend system files. For example, if you create a base controller that other controllers should extend, then you would place it in this directory
- helpers – this directory of CodeIgniter 4 folder structure is used for user-defined helper functions
- hooks – used for custom hooks in CI folder structure
- 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 many packages that you or other developers have created.
- Views – application views go into this directory
CodeIgniter System Subdirectories
Let’s now look at system subdirectories in CI file structure. Remember this is where the framework source code resides. Therefore, don’t make any changes to the files in this directory.
- core – this is like the heart of the CodeIgniter Framework. All of the core file that makes up the framework are located in 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 a new behavior that you wish. You should never make changes directly in here.
- database – database drivers, cache and other files need 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 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.
CodeIgniter User_guide Directory
This file serves as a reference guide for you when you want to understand the CodeIgniter API. You should not upload this directory when deploying your application.
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. 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.
The index.php file directory of CodeIgniter file structure contains the code that will be delivered to the user. This directory is located in the root directory.
- The file structure of CodeIgniter is very important to understand to work effectively with CodeIgniter.
- Core Database, fonts, helpers, language, libraries are important system subdirectories of Application Directory in CodeIgniter structure.
- User guide directory serves as a reference guide for you when you want to understand the CodeIgniter API. This is the entry point into the application and no changes should be made to this directory of CodeIgniter project structure.
- Vendor directory contains source files for packages that you install via composer. This directory in CodeIgniter system folder contains source files for packages that you can install via composer.