CodeIgniter - Application Architecture

CodeIgniter - Application Architecture

The architecture of the CodeIgniter application is shown below.

  • As shown in the figure, whenever a request comes into CodeIgniter, it first goes to the index.php page .
  • In the second step , the routing decides whether to pass this request to step 3 for caching or to pass this request to step 4 for security checks.
  • If the requested page is already in cached mode , the routing service will pass the request to stage 3 and the response will be returned to the user.
  • If the requested page does not exist in the cache , then the routing service passes the requested page to step 4 for security checks .
  • Before passing the request to the Application Controller , the submitted data is checked for security . After security checks, the application controller loads the necessary models, libraries, helpers, plugins, and scripts and passes them to the View .
  • The view will render the page with the available data and submit it for caching . Since the requested page was not previously cached, so this time it will be cached in Caching to quickly process that page for future requests.

As shown in the figure, whenever a request comes into CodeIgniter, it first goes to the index.php page .

In the second step , the routing decides whether to pass this request to step 3 for caching or to pass this request to step 4 for security checks.

If the requested page is already in cached mode , the routing service will pass the request to stage 3 and the response will be returned to the user.

If the requested page does not exist in the cache , then the routing service passes the requested page to step 4 for security checks .

Before passing the request to the Application Controller , the submitted data is checked for security . After security checks, the application controller loads the necessary models, libraries, helpers, plugins, and scripts and passes them to the View .

The view will render the page with the available data and submit it for caching . Since the requested page was not previously cached, so this time it will be cached in Caching to quickly process that page for future requests.

Directory structure

The image below shows the CodeIgniter directory structure.

CodeIgniter directory structure is divided into 3 folders −

  • application
  • system
  • User guide

application

As the name implies, the Application folder contains all the code for your application that you create. This is the folder where you will develop your project. Application folder contains several other folders which are described below −

  • Cache - This folder contains all cached pages of your application. These cached pages will increase the overall page access speed.
  • Config - This folder contains various files for configuring the application. Using the config.php file , the user can configure the application. Using the database.php file , the user can set up the application's database.
  • Controllers - This folder contains your application's controllers. This is the main part of your application.
  • Core - This folder will contain the base class of your application.
  • Helpers - This folder is where you can put your application's helper class.
  • Hooks - The files in this folder provide the ability to plug in and change the inner workings of the framework without breaking the core files.
  • Language - This folder contains language related files.
  • Libraries - This folder contains the files of the libraries developed for your application.
  • Logs - This folder contains files related to the system log.
  • Models - The database login will be placed in this folder.
  • Third_party - in this folder you can place any plugins that will be used for your application.
  • Views - The application's HTML files will be placed in this folder.

Cache - This folder contains all cached pages of your application. These cached pages will increase the overall page access speed.

Config - This folder contains various files for configuring the application. Using the config.php file , the user can configure the application. Using the database.php file , the user can set up the application's database.

Controllers - This folder contains your application's controllers. This is the main part of your application.

Core - This folder will contain the base class of your application.

Helpers - This folder is where you can put your application's helper class.

Hooks - The files in this folder provide the ability to plug in and change the inner workings of the framework without breaking the core files.

Language - This folder contains language related files.

Libraries - This folder contains the files of the libraries developed for your application.

Logs - This folder contains files related to the system log.

Models - The database login will be placed in this folder.

Third_party - in this folder you can place any plugins that will be used for your application.

Views - The application's HTML files will be placed in this folder.

system

This folder contains the core CodeIgniter codes, libraries, helpers, and other files that help make coding easier. These libraries and helpers are downloaded and used in web application development.

This folder contains all subsequent CodeIgniter code organized into various folders −

  • Core - This folder contains the CodeIgniter base class. Don't change anything here. All your work will take place in the application folder. Even if your intention is to extend the core of CodeIgniter, you must do so with hooks, and hooks live in the application folder.
  • Database - The database folder contains the main database drivers and other database utilities.
  • Fonts - The Fonts folder contains information about fonts and utilities.
  • Helpers . The helpers folder contains the standard CodeIgniter helpers (such as date, cookie, and URL helpers).
  • Language - The language folder contains language files. You can ignore it for now.
  • Libraries . The libraries folder contains the standard CodeIgniter libraries (to help you with email, calendars, file uploads, and more). You can create your own libraries or extend (and even replace) the standard ones, but they will be saved in the application/library directory to separate them from the standard CodeIgniter libraries saved in that particular folder.

Core - This folder contains the CodeIgniter base class. Don't change anything here. All your work will take place in the application folder. Even if your intention is to extend the core of CodeIgniter, you must do so with hooks, and hooks live in the application folder.

Database - The database folder contains the main database drivers and other database utilities.

Fonts - The Fonts folder contains information about fonts and utilities.

Helpers . The helpers folder contains the standard CodeIgniter helpers (such as date, cookie, and URL helpers).

Language - The language folder contains language files. You can ignore it for now.

Libraries . The libraries folder contains the standard CodeIgniter libraries (to help you with email, calendars, file uploads, and more). You can create your own libraries or extend (and even replace) the standard ones, but they will be saved in the application/library directory to separate them from the standard CodeIgniter libraries saved in that particular folder.

User guide

This is your CodeIgniter user guide. This is basically the offline version of the user guide on the CodeIgniter site. Using this, you can explore the functions of various libraries, helpers, and classes. Before creating your first web application in CodeIgniter, it is recommended that you review this user guide.

Apart from these three folders, there is another important file named " index.php ". In this file, we can set the application environment and error level, and define the system and application folder name. It is recommended that you do not edit these settings unless you have sufficient knowledge of what you are about to do.