Codeigniter is popular due to CodeIgniter libraries which plays an essential role in the development of the application. These libraries increase the speed of development indirectly.

By default, these libraries are available under the system folder of the application. We have to load these libraries whenever we need. You can load any library by using the following syntax.

$this->load->library('library_name');

There are many libraries available in CodeIgniter based on unique purposes such as if you want to work with “email” so you have to use email library.

In the following example we are going to load email library.

$this->load->library('email');

List of CodeIgniter Libraries

S.N. Libraries & Description
01 CodeIgniter Benchmarking Class

The benchmark always starts when the frame is invoked and ends with the output class immediately before the final view is sent to the browser, allowing a very precise timing of the entire system execution.

02 CodeIgniter Caching Class

This class will reserve the pages, to rapidly get page speed.

03 CodeIgniter Calendaring Class

You can create calendars dynamically using this class.

04 CodeIgniter Shopping Cart Class

You can add or remove item from the Shopping Cart using this class. The items are saved in session and remain active until the website is visited by the user.

05 CodeIgniter Config Class

Using this class, configuration preferences can be obtained. This class is automatically initialized.

06 CodeIgniter Email Class

This class offers e-mail related functionality such as e-mail sending or replying.

07

CodeIgniter Encryption Class

This class offers two – way encryption capabilities.

08

CodeIgniter File Uploading Class

This class provides file uploading features. You can set different preferences, such as file type to upload, file size, etc.

09

CodeIgniter Form Validation Class

This class provides various validation functions.

10

CodeIgniter FTP Class

This class offers various FTP related functions such as file transfer to remove server, move, rename or delete server files.

11

CodeIgniter Image Manipulation Class

With this class, image manipulation such as resizing, thumbnail creation, cropping, rotating and watermarking can be done.

12

CodeIgniter Input Class

For security purposes, this class processes the input data.

13

CodeIgniter Language Class

For internationalization this class is used.

14

CodeIgniter Loader Class

This class loads items such as view files, drivers, helpers, models, etc.

15

CodeIgniter Migrations Class

This class provides database migration functionality.

16

CodeIgniter Output Class

This class sends output to the browser and caches the website as well.

17

CodeIgniter Pagination Class

This class adds pagination features to the web page.

18

CodeIgniter Template Parser Class

The template parser class can easily substitute text for pseudo variables in your view files. Simple variables or tag pairs can be parse easily.

19

CodeIgniter Security Class

This class contains security related functions like XSS Filtering, CSRF etc.

20

CodeIgniter Session Library

This class provides functionalities to maintain session of your application.

21

CodeIgniter HTML Table Class

This class is used to auto-generate HTML tables from array or database results.

22

CodeIgniter Trackback Class

The Trackback Class offers functions that allow trackback data to be sent and received.

23

CodeIgniter Typography Class

The typography class provides methods for formatting text.

24

CodeIgniter Unit Testing Class

This class provides functionalities to test and generate results for your application.

25

CodeIgniter URI Class

The URI Class offers methods to get information from your URI strings. You can also get information about the re – routed segments if you use URI routing.

26

CodeIgniter User Agent Class

The User Agent Class provides key functions that help us identify information about your website visiting your browser, mobile device or robot. You can also obtain referrer data, language and character set information.

27

CodeIgniter XML-RPC and XML-RPC Server Classes

The XML-RPC classes of CodeIgniter allow you to send requests to a different server or set up your own XML-RPC server for requests.

28

CodeIgniter Zip Encoding Class

This class is used to create your data’s zip archives.

 

Creating CodeIgniter Libraries

CodeIgniter has a rich set of libraries in the system/libraries folder, but CodeIgniter is not limited to system libraries, you can also create your own libraries that can be stored in the application/libraries folder. In three ways, you can create libraries.

  • Create New CodeIgniter library
  • Extend the Native CodeIgniter library
  • Replace the Native CodeIgniter library

Create New CodeIgniter library

Bear in mind the following things during the creation of a new codeigniter library.

  • The filename must begin with a capital letter, e.g. Tutorialpace_library
  • The name of the class must start with a capital letter, e.g. class Tutorialpace_library
  • The class name and file name must match.

Tutorialpace_library.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
   
   class Tutorialpace_library{
  
      public function main_function() {
      }
   }
  
/* End of file Tutorialpace_library.php */

Custom library loading

You can load the above library simply by running the next line in your controller.

$this->load->library('Tutorialpace_library');

Tutorialpace_library is your library’s name and can be written in both lowercase and upper case letters. Use library name without the extension “.php. ” Once you have loaded the library, you can also call the class function as shown below.

$this->tutorialpace_library->main_function();

Extend the Native CodeIgniter library

Sometimes you may need to add your own functionality to the CodeIgniter library. CodeIgniter provides the facility you can add your own functions to the native library. To do this, the native library class must be extended. If you want to extend the Email library, for example, you can do it as shown below −

Class Tutorialpace_Email extends CI_Email { 
}

In the above example, the Tutorialpace_Email class extends the CI_Email class of the native library.

Replace the Native CodeIgniter library

You don’t want to use the native library in some situations and replace it with your own way. This can be done by substituting the authentic library. To do this, you only have to give the same class name in the native library. If you want to replace the Email class, for example, use the code below. Save your Email.php file name and give CI_Email a class name.

Email.php

Class CI_Email {
 /* Define your own functionalities */ 
}