Using Third-Party Libraries in Codeigniter

This tutorial demonstrates, how to use third party libraries in Codeigniter. While developing web applications we will be dealing third party libraries. We cannot expect  all of your favorite libraries are loaded in package manager, so only way to do it is directly including in the program.

In Codeigniter we have segmented folder called third_party in application folder. It is recommended to keep all your third party libraries in the third_party folder. So it will be very readable for all other developers working in your project.

In this example I used a third party image library php-image-resize. I downloaded from the given GitHub link.

Steps to integrate third party library to Codeigniter project

Step 1: Copy the downloaded third party script to the third_party folder

Step 2: Create a folder called imageResize inside the third_party folder. So your final path would be application/third_party/imageResize/imageResize.php

Step 3: Call this library in the construct function in your controller.

include APPPATH . 'third_party/imageResize/imageResize.php';

Step 4: I have called in a controller called Products.php. 

Controller : Products.php

Below is the final snippet off the function usage in the Products.php

Now you know how to access the third party library in Codeigniter.

You may be interested in reading below articles


Editorial Staff

Editorial Staff at tutsplanet is a dedicated team to write various tutorial articles.