Codeigniter Create custom library

Codeigniter Create custom library

Today, We want to share with you Codeigniter Create custom library.In this post we will show you how to use any library in codeigniter, hear for codeigniter load library in controller we will give you demo and example for implement.In this post, we will learn about How to create custom library file in codeigniter 3 with an example.

Codeigniter Create custom library

There are the Following The simple About Codeigniter Create custom library Full Information With Example and source code.

Read Also:  Vue.js Hello World

As I will cover this Post with live Working example to develop how to create plugin in codeigniter, so the create custom library codeigniter Directory structures for this example is following below.

Create a CodeIgniter Libraries

Step 1:-Create Custom Library

first of all you Go to application/libraries as well as here create a new file Yourfilename_lib.php like as a Convertlibrary.php.

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source CodeIgniter application development framework for PHP 7.1 or newer
 *
 * @package     CodeIgniter
 * @author      pakainfo
 * @copyright           Copyright (c) 2021, pakainfo.
 * @license     
 * @link        https://www.pakainfo.com
 * @since       Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * pakainfo core CodeIgniter class
 *
 * @package     CodeIgniter
 * @subpackage          Libraries
 * @category            pakainfo
 * @author      pakainfo
 * @link        https://www.pakainfo.com
 */

CodeIgniter load pre-defined libraries

class Convertlibrary{
    private $CI;
    public function __construct()
    {
        $this->CI =& get_instance();
        $this->CI->load->helper('url');       
        $this->CI->load->database();
        
    }

   function show()
    {
        // Your main logic
    }
}

CodeIgniter load the library

    $this->load->library('convertlibrary');

Step 3: your library method in controller (In any controller)

$this->convertlibrary->show();

Web Programming Tutorials Example with Demo

Read :

Read Also:  WordPress Create Plugin From Scratch

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Codeigniter Create custom library.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

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