In this tutorial you will learn about the Codeigniter Directory Structure and its application with practical example.
After downloading the CodeIgniter framework, as you extract it you will get the Codeigniter framework file hierarchy as shown below –
A codeIgniter application is basically divided into three folders those are as following –
Application
System
User_guide
Also some loose files are there such as index.php, license.txt etc. In addition, You are free to create and use directory to manage your assets like images, scripts etc. All of the folders and files have some functionality associated with them.
CodeIgniter Application Folder Structure
As its name suggests the application directory is main directory in CodeIgniter framework, this is the directory where you keep the entire application code that you are developing. In addition, application directory contains several other sub-directories including controllers, models, and views as shown below.
Cache – This directory is meant to store cached page of your application. Cache is a technique that gives way to serve page content faster.
Config – The Config directory contains all configuration of your application. For example, Config.php contain the configuration of Base URL, Index file, URI Protocol etc. Database.php contains the configuration of the database like database driver, database name, username, password etc.
Controller – This directory contains all controller of your application.
Core – This directory contains all base classes of your application.
Helpers – This directory contains all of the helper functions and classes.
Hooks – The Hooks feature gives you way to tap into and modify the inner workings of the framework without hacking the core files of your codeigniter framework. For example, you might want to run a script right before your controllers get loaded, or right after, or you might want to trigger one of your own scripts in some other location.
Language – This directory contains all of the language files for your application.
Libraries – All system library are contained in the system directory. But you can define your own library in the libraries directory.
Logs – This directory contains files related to the log of the system.
Models – This directory contains all of the your database models.
Third_party – In this directory, you can place all of the third party plugins, which will be used in your application.
Views – In this directory you keep all of the templates files for your application.
CodeIgniter System Folder Structure
The system directory contains all of the core libraries, helpers and other core files. It is recommended to not change anythings in this directory. This directory contains all the CodeIgniter framework code of consequence, organized into various other sub-directories, as explained below –
Core – This folder contains the core classes essential for proper working of the framework. Please do not try to change any file in this directory.
Database – This folder contains core database files like cache, driver, query builder etc.
Fonts – This folder have fonts related files.
Helpers – The helper folder contains standard codeigniter helpers like url helper, array helper, date helper, cookie helper etc.
Libraries – This folder contains standard codeigniter libraries. You can create your own library in application/libraries.
Language – This folder contain language files.
CodeIgniter User_guide Folder Structure
This folder actually a offline version of the user guide website. It helps you to learn and understand Codeigniter framework directory structure, basics and functions, classes and the helpers.
CodeIgniter index.php file
In this file, you can setup the application environment, error level and also you can define system, application and view folder path. If you are new to codeigniter, it is recommended not to change index.php code.