Blog

CodeIgniter and Basic Concepts

CodeIgniter is a toolkit to build web applications using PHP. Codeigniter is an application framework. Its goal is to enable to develop projects much faster, by providing a rich set of libraries.

Truly lightweight, really fast uses the Model-View-Controller approach, which allows great separation between logic and presentation. The core system requires only a few very small libraries. 

List of CodeIgniter’s main features:

  • Model-View-Controller Based System
  • Extremely Light Weight
  • Full Featured database classes with support for several platforms.
  • Query Builder Database Support
  • Form and Data Validation
  • Security and XSS Filtering
  • Session Management
  • Email Sending Class. Supports Attachments, HTML/Text email, multiple protocols (sendmail, SMTP, and Mail) and more.
  • Image Manipulation Library (cropping, resizing, rotating, etc.). Supports GD, ImageMagick, and NetPBM
  • File Uploading Class
  • FTP Class
  • Localization
  • Pagination
  • Data Encryption
  • Benchmarking

Codeigniter's Flow:

  1. The index.php serves as the front controller, initializing the base resources needed to run CodeIgniter.
  2. The Router examines the HTTP request to determine what should be done with it.
  3. If a cache file exists, it is sent directly to the browser, bypassing the normal system execution.
  4. Security. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security.
  5. The Controller loads the model, core libraries, helpers, and any other resources needed to process the specific request.
  6. The finalized View is rendered then sent to the web browser to be seen. If caching is enabled, the view is cached first so that on subsequent requests it can be served.

CodeIgniter directory structure:

  • Application
  • System
  • User_guide

Application folder contains the code of your application that you are building. All the files which belong to your project will be in this folder. The Application folder contains some other folders, which listed below:

Cache : It contains all the cached pages of your application. These pages will increase speed of accessing the pages.

Config : It contains configure files of the application. Ex: config.php file, user can configure the application. database.php file, user can configure the database of the application.

Controllers : It contains the controllers of your application. It is the basic part of your application.

Core : It contain base class of your application.

Helpers : In this folder we can put helper files of your application.

Hooks : The files in this folder provide a means to tap into and modify the inner workings of the framework without hacking the core files.

Language : It contains language related files.

Libraries : It contains files of the libraries developed for your application. We can create our own libraries or extend the core.

Logs : It contains files related to the logs of the system.

Models : It contain model classes file which use to get or insert data into database.

Third_party : This folder used to place any plugins, which will be used for the application.

Views : Application’s HTML files will be placed in this folder.

System Folder:

This folder contains CodeIgniter core codes files, such as libraries, helpers and other files, which help make the coding easy. These libraries and helpers are loaded and used in web app development.

This folder contains all the CodeIgniter code of consequence, organized into various folders

Core : It contains CodeIgniter’s core class.

Database : It contains core database drivers and other database utilities.

Fonts : It contains font related information and utilities.

Helpers : It contains standard CodeIgniter helpers files such as date, cookie, and URL helpers.

Language : It contains language files.

Libraries : It contains standard CodeIgniter libraries Such as e-mail, calendars, file uploads, and many more.

User Guide:

CodeIgniter documentation file.

CodeIgniter is based on MVC(Model-View-Controller) pattern: 

The Model contain model classes those help you retrieve, insert, and update information in your database.

Syntax of Model:

To create Model go to Application/models folder 


<!--?php 
    
      Public function __construct() { 
         parent::__construct(); 
      } 
   } 
?> 

The View is the information that is being presented to a user. A View will normally be a web page, but in CodeIgniter, a view can also be a page fragment like a header or footer.

The Controller serves as an intermediary between Model, View, and any other resourse. We created a controller and extend that controller. In that controller we define all the generic method and used in other controllers.

Syntax of Controller:

To create controller first go to Application/controllers folder

<!--?php 
  
      public function index() { 
         echo "Hello World!"; 
      } 
   } 
?>







In order to give you better service we use cookies. By continuing to use our website, you agree to the use of cookies as described in our Privacy Policy