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

Tutsplanet

Free Technical and Blogging Resources

  • Home
  • Web Hosting
  • Programming
  • Plugins
  • Twitter Trends
  • Tools
  • About Us

Programming TagsCodeigniter

Using Third-Party Libraries in Codeigniter

Sep 23, 2017 Editorial Staff Leave a Comment

Share
Tweet
Share
13 Shares

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

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

  • Top 21 Website Ideas To Make Money Online in 2021
  • A Simple YouTube Video Downloader Script in PHP
  • The 50 Most Useful jQuery Plugins for Frontend Development
  • Replace “\n” with new line characters, using Notepad++
  • Using Third-Party Libraries in Codeigniter
  • Upload Multiple Images and Store in Database using PHP and MySQL.
  • Hierarchical Tree view Category Example in Laravel
  • Laravel Image Intervention Tutorial With Example
  • How to import sql file in MySQL database using PHP?
  • Free VAT Calculator Online

Subscribe

* indicates required



Search Here

Share

   



Hot topics

  • Replace “\n” with new line characters, using Notepad++ 15 views
  • Solution: windows photo viewer opens each time save a pic file 12 views
  • A Simple YouTube Video Downloader Script in PHP 10 views
  • How to Create PDF File From HTML Form Using Fpdf? 9 views
  • All Countries SQL file with Country Codes to Download 8 views
  • How to create and download a Zip file with PHP 8 views
  • Simple PHP Shopping Cart 7 views
  • How to set up GitHub SSH in Ubuntu with example 7 views
  • How to enter new line in Microsoft Teams? 7 views
  • Laravel Eloquent Select Column as Alias 7 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 © 2023 · Planet on Genesis Framework · Powered By BunnyCDN . Network wallpapernoon.com