How to create custom library in CodeIgniter

Create custom library in CodeIgniter

CodeIgniter libraries are collection of classes located in libraries folder(i.e, application/libraries and system/libraries). Libraries are used to make the collection of related methods. You can make as many libraries in CodeIgniter as per your convenience.

Let’s start the tutorial for create custom library in CodeIgniter.

create-library-in-codeigniter

Make a file demo.php in application/libraries and paste the below code:

Use the library

In your controller say “admin.php” in application/controllers load library as shown below:

That’s all. You have successfully created your custom library in CodeIgniter.

Enjoy Coding!!

 

Share This:

Leave a Reply