codeigniter file structure

CodeIgniter Folder, File Structure

Codeigniter File or folder Structure is essential to work on CodeIgniter project mostly beginners got confused to learn in which directory what file? Let's see the folder structure of CodeIgniter after downloading:

CodeIgniter has the following structure:

1. Application

2. System

3. User_guide

4. index.php file

 

CodeIgniter Application folder

 the application folder is the place where we work to develop a project means it contains all essential  files  such as views, controller, config, routes, etc. let's see its subdirectories:

1. Cache folder:  This folder is used to store the cache of your project to increase the page speed of your project. We cache our media files such as CSS, images, js to load our page fast on the browser. Mainly developer also uses cache in the .htaccess file.

2. Config folder:  As its name suggests, it contains config files of your project such as database configuration file, base URL and session related work config file, routes URL related config file. There are several files we are explaining some critical files on which most developers work:

  • Autoload file: In this file, we load our model file, libraries, and helper. It saves our time; if we load our file in autoload, then it is available by all means; there is no need to load files one by one in the controller.

Example: 
 
$autoload['libraries'] = array('database', 'email', 'session','cart','form_validation');
 
$autoload['model'] = array('admins','banners','categoriess','crud','products','page');  

 
  • Config file: In this file, we set our base URL, config our session time or session-related work, and we also set URL prefix.
  • Database file: In this file, we set our database connection.
  • Routes: In this file, we set our URL, which means what kind of URL we want to use for digital marketing or SEO purposes.

Example :
$route['default_controller'] = 'welcome';
 
$route['sitemap\.xml'] = "welcome/sitemap";
 
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
 
/**********************************************************/
$route['category/(:any)'] = 'welcome/category/$1';
$route['search/(:any)'] = 'welcome/searchbyattribute/$1';
$route['searchbycategory/(:any)'] = 'welcome/searchbycategory/$1';
 
  • Hooks:  In this file, we config our hook-related code.

3. Controllers folder: The Controller is an important folder containing our logic and works as a mediator between views and models file. It loads our view page by its function, and also it connects our model's page to the view page.

Necessary:  When you create a controller, you should keep one point in mind: your file name and class name should be the same, and the filename and class name of the first character should be uppercase.

4. Core folder: The core folder has nothing special it is rarely used. As its name tells about itself, it contains core custom classes that extend system files.

5. Helpers: This folder is used to contain a user-defined helper function. Helper is like a function that is used repeatedly in the project.

6. Hooks: In this folder, we create a hook file that works as middleware; for example, we want to protect some pages and check the user login first; then hook is very helpful. By using a hook, we can check the user first then show the page.

If we don’t use; then we have to write code on all protected page to check user login.

7. Language: In this folder, we create files and write language-related settings.

8. Libraries: In this folder, we contain user-defined libraries, for example, CSV upload library, multiple file upload library.

9.Logs: This folder contains your error logs.

10.Models:  This folder contains our model's fil containings database-related code such as insert and update delete code.

11.Third_Party: This folder is used to keep third-party API libraries such as payment gateway, message API-related files.

12. Views: This folder contains our HTML pages.

 

CodeIgniter System  folder

The system folder contains subdirectories that are helpful to run our CodeIgniter. Remember, It contains our CodeIgniter Framework-related code, so beginner developer don’t make any changes.

  • Core:  It contains the core file of the CodeIgniter framework; it is the heart of the CodeIgniter Framework. It contains controller, Uri, model-related code, which we extend in our controller model file.
  • Database: It contains the core code of database drivers and cache.
  • Fonts: It contains fonts-related information.
  • Helper: It contains default helpers such as URL, date.
  • Language: It contains the default language file.
  • Libraries: It contains default libraries of CodeIgniter such as file upload, email, etc.

 

CodeIgniter User_Guide  folder

This folder contains offline documentation of CodeIgniter Framework, where developers can learn offline. You should remove this folder outside because it creates extra space.

CodeIgniter index.php File

Our CodeIgniter first searches the index.php file from where it runs. We can set our development mode in this file, such as production mode, development mode, testing mode, in localhost. We use development mode for debugging purposes, and in live hosting, we use production mode. In production mode, it does not shows any error if it occurs.

Categories: web development codeigniter

Trending Courses

CodeIgniter

Regular : 45 Days

Fastrack : 20 Days

Crash : 10 Days

Advance Digital Marketing

Regular : 6 Months

Fastrack : 3 Months

Crash : 2 Months

React JS

Regular : 45 Days

Fastrack : 20 Days

Crash : 7 Days

Laravel

Regular : 45 Days

Fastrack : 20 Days

Crash : 10 Days

Front End Developer

Regular : 7 Month

Fastrack : 4 Month

Crash : 2 Month

Request For Demo