Codeigniter Architecture

Codeigniter

Codeigniter is one of the PHP framework. CodeIgniter was created with the following objectives, these are copied from codeigniters user guide:

  • Dynamic Instantiation. In CodeIgniter, components are loaded and routines executed only when requested, rather than globally. No assumptions are made by the system regarding what may be needed beyond the minimal core resources, so the system is very light-weight by default. The events, as triggered by the HTTP request, and the controllers and views you design will determine what is invoked.
  • Loose Coupling. Coupling is the degree to which components of a system rely on each other. The fewer components depend on each other the more reusable and flexible the system becomes. Our goal was a very loosely coupled system.
  • Component Singularity. Singularity is the degree to which components have a narrowly focused purpose. In CodeIgniter, each class and its functions are highly autonomous in order to allow maximum usefulness.

The below diagram shows codeigniter architecture.

index.php: In codeigniter, every request is passing through index.php page. Which is the default file of codeigniter.

config: The config folder contains necessary files for configuring the application like security,database connection,URL handling etc. For example we can set the base URL in config.php page. To configure the database, use database.php file.

Library: Library folder consists of class files.These class files are required classes. Controllers,models,config uses libraries.

Helpers: Helper folder includes necessary helper files for your application. For example setting base_url and site_url we can use URL helpers,form helpers for creating forms, etc.

Controller: All the requests are received by the controller and are passed on to models and view to process the information. Controllers are the intermediary to handle the HTTP request and response in your application.

Model: Model classes includes necessary function to manage the database quires like insert,update,select,delete etc.  Models are managed by controllers.

View:Views folder contains the HTML files or the web pages.The View is the information that is being presented to a user.Views are php files and are managed by controller.

Leave a Reply

Your email address will not be published. Required fields are marked *