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.

S.N.

Library Class & Description

1

Benchmarking Class

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

2

Caching Class

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

3

Calendaring Class

Using this class, you can dynamically create calendars.

4

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.

5

Config Class

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

6

Email Class

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

7

Encryption Class

This class provides two-way data encryption functionality.

8

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.

9

Form Validation Class

This class provides various functions to validate form.

10

FTP Class

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

11

Image Manipulation Class

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

12

Input Class

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

13

Language Class

This class is used for internationalization.

14

Loader Class

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

15

Migrations Class

This class provides functionalities related to database migrations.

16

Output Class

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

17

Pagination Class

This class adds pagination functionalities to web page.

18

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.

19

Security Class

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

20

Session Library

This class provides functionalities to maintain session of your application.

21

HTML Table

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

22

Trackback Class

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

23

Typography Class

The Typography Class provides methods that help to format text.

24

Unit Testing Class

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

25

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.

26

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.

27

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.

28

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.

Mylibrary.php


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 © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

CodeIgniter Topics