• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
logo

Tutsplanet

Free Technical and Blogging Resources

  • Home
  • Web Hosting
  • Programming
  • Plugins
  • Write For US
  • News
  • About Us
  • Snippets
You are here: Home / Programming / Using Third-Party Libraries in Codeigniter

Using Third-Party Libraries in Codeigniter

Sep 23, 2017 by Editorial Staff Leave a Comment

This tutorial demonstrates, how to use third party libraries in Codeigniter. Codeigniter is capable to make any kind of websites like blogging websites,Informational Websites,Ecommerce Websites or social media websites, with any size. 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

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Products extends CI_Controller {

	public function __construct() {
		parent::__construct();		
		include APPPATH . 'third_party/imageResize/ImageResize.php';
	}

	public function image_resize() {

		$image = new \Eventviva\ImageResize($this->config->item('image_main').$fname);
        $image
		    ->resizeToWidth(500,300)
		    ->save($this->config->item('image_large').$fname)

		    ->crop(100, 100)
		    ->save($this->config->item('image_small').$fname)
		;
	}
}

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

You may be interested in reading below articles

  • Best CodeIgniter Tutorials for Beginners
  • CodeIgniter – Basic Concepts 

 


Editorial Staff

Editorial Staff at Tutsplanet is a dedicated team to write various tutorials about subjects like Programming, Technology and Operating Systems.

View all posts by Editorial Staff

Filed Under: Programming Tagged With: Codeigniter

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar




Quick Links

  • A Simple YouTube Video Downloader Script in PHP
  • The 50 Most Useful jQuery Plugins for Frontend Development
  • Base64 Decode Online
  • Base64 Encode Online

Subscribe

* indicates required

Share

   

Hot topics

  • A Simple YouTube Video Downloader Script in PHP 268 views
  • Replace “\n” with new line characters, using Notepad++ 242 views
  • Add FTP/SFTP in Visual Studio Code 176 views
  • Open a URL in a new tab using JavaScript 140 views
  • Using Third-Party Libraries in Codeigniter 138 views
  • Upload Multiple Images and Store in Database using PHP and MySQL. 130 views
  • Laravel Image Intervention Tutorial With Example 125 views
  • Hierarchical Tree view Category Example in Laravel 112 views
  • Spout, an awesome library for reading and writing in Excel. 101 views
  • Manually Install APK Files In Android Studio Emulator 98 views

Categories

  • Design & Development
  • Drupal
  • Facebook
  • General
  • How To
  • ios
  • Javascript
  • Linux
  • Magento
  • Marketing
  • News
  • PHP
  • Plugins
  • Programming
  • Snippets List
  • Social Media
  • Softwares
  • Themes
  • Tips
  • Wordpress
  • YouTube

Copyright © 2021 · TutsPlanet Gene Theme on Genesis Framework · Powered By BunnyCDN