It is very important to understand the file structure in CodeIgniter if you want to develop applications successfully.
The following image shows the file structure in CodeIgniter
Let’s now look at the above files
- 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
As we stated above, this directory contains the application code. In this section, we will look at the internal subdirectories
- 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 is used for user-defined helper functions
- hooks – used for custom hooks
- 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
Let’s now look at system subdirectories. 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 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 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.
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.
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.
This directory contains source files for packages that you install via composer
- 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
- 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.
- Vendor directory contains source files for packages that you install via composer. This directory contains source files for packages that you can install via composer