File structure in CodeIgniter
After unzipping the CodeIgniter folder you will get a file hierarchy of CodeIgniter files as shown below.
CodeIgniter file structure is mainly divided into three parts:
Application folder is the main development folder for you where you will develop your project. It contains your models, views, controllers, configuration and many other files. It contains all the code of the project you are working on.
- Cache - Cache stores the processed data so that this data can be easily loaded within no time for the future use. It increases the speed of your page access.
- Config - The config folder contains configuration files as shown below. These files allow configuring CodeIgniter application.
Look at the above snapshot, autoload.php file will load your libraries, helpers or you can define custom files so you don't have to call them again and again in your project. In config.php file we set our base-url etc. In database.php file we need to configure our database setting to connect it from our project. In routes.php file you can set your default controller page.
- Controllers - Web application flow is controlled by the controller. All the server-side functionalities are handled by the controller. In short, it controls the CodeIgniter application. If controller fails all the work associated with it will also fail, just like CPU in a computer.
Name of the controller class file will always start with an uppercase letter. For example, it will be named like Main.php and not main.php.
- Core - CodeIgniter has some core class, these class make up the CodeIgniter framework and are saved in core file.
Generally, there will be no need to change these classes, but in case if you are modifying a class, create a class in "application/core" folder having same name as the core class file name in "system" folder.
- Helpers - A helper helps you to complete task in CodeIgniter. For example,
$this->load->helper('form'); will create a form that will work perfectly with CodeIgniter. And
$this->load->helper('date'); will get you date features in your applications.
- Hooks - This folder meddles into the inner working of flow of application.
- Language - With the help of this folder you can create text files with specific language and can use them in your project.
- Libraries - In this folder you can store libraries developed by you for your application.
- Logs - If your CodeIgniter application is displaying some error or exception handling messages and if you are not getting what they are, you can look for their explanation in this folder.
- Models - Models are used to load database queries. Controllers request model to load database query, model respond it back and then controller use it.
- Third_party - Third party plugins are stored in this folder to use in the application.
- Views - It contains all your html files. Controller load file from view and then gives the output.
All action of CodeIgniter application happens here. It contains files which makes the coding easy.
- Core - It contains CodeIgniter core class. Do not make any changes in this folder.
- Database - It contains database drivers and other utilities.
- Fonts - It contains font related information.
- Helpers - It contains default helpers such as URL, date and cookie.
- Language - CodeIgniter supports multilingual web applications. It contains default language file.
- Libraries - It contain libraries like calendars, file upload, email, etc. libraries created by you will be saved in "application/libraries". Here, only standard libraries will be stored.
It is the offline CodeIgniter guide. It comes with every CodeIgniter downloaded version. In case of any query, you can read its user guide. You can learn here all the functions, libraries, helpers of CodeIgniter. Before starting use of CodeIgniter go through this guide once.
Last but not least, you can see a file index.php. Here we can set application environment and error level. It is better not to touch this file if don?t have sufficient knowledge.