CodeIgniter Libraries - CodeIgniter

What are CodeIgniter Libraries?

The essential part of a CodeIgniter framework is its libraries. It presents a rich set of libraries, which indirectly increase the rate of developing a utility. The system library is placed at system/libraries. All we want to do is to load the library that we need to apply. The library may be loaded as shown beneath –

Where the class-name is the name of the library that we want to load. If we need to load more than one library, then we can absolutely pass an array as argument to library () function as shown under –

What are Library classes?

The library classes are located in device/libraries. Every class has various features to simplify the developing work. Following table shows the names of the library class and its description.

Given below are the most commonly used Library Classes.


Library Class & Description


Benchmarking Class

Benchmarking class is always active, enabling the time difference between any two marked points to be calculated.


Caching Class

This class will cache the pages, to quickly access the page speed.


Calendaring Class

Using this class, you can dynamically create calendars.


Shopping Cart Class

Using this class, you can add or remove item from Shopping Cart. The items are saved in session and will remain active until the user is browsing the site.


Config Class

Configuration preferences can be retrieved, using this class. This class is initialized automatically.


Email Class

This class provides email related functionality, like send or reply to email.


Encryption Class

This class provides two-way data encryption functionality.


File Uploading Class

This class provides functionalities related to file uploading. You can set various preferences like type of file to be uploaded, size of the files etc.


Form Validation Class

This class provides various functions to validate form.


FTP Class

This class provides various FTP related functions like transferring files to remove server, moving, renaming or deleting files on server.


Image Manipulation Class

Manipulation of image like resize, thumbnail creation, cropping, rotating, watermarking can be done with the help of this class.


Input Class

This class pre-processes the input data for security reason.


Language Class

This class is used for internationalization.


Loader Class

This class loads elements like View files, Drivers, Helpers, Models etc.


Migrations Class

This class provides functionalities related to database migrations.


Output Class

This class sends the output to browser and also, caches that webpage.


Pagination Class

This class adds pagination functionalities to web page.


Template Parser Class

The Template Parser Class can perform simple text substitution for pseudo-variables contained within your view files. It can parse simple variables or variable tag pairs.


Security Class

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


Session Library

This class provides functionalities to maintain session of your application.


HTML Table

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


Trackback Class

The Trackback Class provides functions that enable you to send and receive Trackback data.


Typography Class

The Typography Class provides methods that help to format text.


Unit Testing Class

This class provides functionalities to unit test your application and generate the result.


URI Class

The URI Class provides methods that help you retrieve information from your URI strings. If you use URI routing, you can also retrieve information about the rerouted segments.


User Agent Class

The User Agent Class provides functions that help identify information about the browser, mobile device, or robot visiting your site. In addition, you can get referrer information as well as language and supported character-set information.


XML-RPC and XML-RPC Server Classes

CodeIgniter’s XML-RPC classes permit you to send requests to another server, or set up your own XML-RPC server to receive requests.


Zip Encoding Class

This class is used to create zip archives of your data.

Creating Libraries

CodeIgniter has rich set of libraries, which you could find in system/libraries folder however CodeIgniter is not simply restricted to system libraries, you can create your personal libraries too, which may be saved in software/libraries folder. you could create libraries in three methods.

  • Create new library
  • extend the native library
  • replace the native library
  • Create New Library

While creating new library one ought to keep in thoughts, the subsequent things −

  • The name of the document must begin with a capital letter e.g. Mylibrary.php
  • The elegance name must begin with a capital letter e.g. class Mylibrary
  • The name of the elegance and call of the report must fit.


Loading the custom Library

The above library may be loaded by simply executing the following line on your controller.

Mylibrary is the name of your library and you may write it in lowercase as well as uppercase letters. Use the call of the library without “.php” extension. After loading the library, you could additionally call the feature of that class as proven under.

Extend the native Library

Once in a while, you could need to add your personal capability to the library provided by CodeIgniter. CodeIgniter presents facility by way of which you may extend the native library and upload your personal capabilities. To acquire this, you need to amplify the class of native library class. As an example if you need to increase the e-mail library then it is able to be carried out as shown under –

Here, in the above instance, MY_Email class is extending the local library’s email class CI_Email. This library can be loaded through the same old way of loading e mail library. keep the above code in file My_Email.php

Replace the native Library

In a few conditions, you do not want to use the local library the way it really works and want to update it along with your own manner. This may be accomplished by using replacing the native library. To achieve this, you simply want to give the equal class name as it is named in native library. For instance, if you need to replace the email class, and then use the code as shown under. Save your report name with e mail.php and give a category name to CI_Email.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

CodeIgniter Topics