How to create custom library file in codeigniter 3?
Sometimes, we might be require to make custom library in php codeigniter project. so we can load custom library quickly and use that functions.
you can see step by step tutorial of creating custom library file in codeigniter 3 application. just follow bellow few steps to create your own library for your codeigniter 3 project.
first let's create library file in libraries folder of your app.
application/libraries/Mylibrary.php
<?php
class Mylibrary {
function my_first_call()
{
return 'Hello, ItSolutionStuff.com';
}
}
?>
now create one route for testing so let's register one route for calling custom library function.
application/config/routes.php
$route['my-library'] = "MyLibraryController";
Now just create controller for testing call of created custom library in codeigniter app. let's create controller like as bellow:
application/controllers/MyLibraryController.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class MyLibraryController extends CI_Controller {
/**
* Get All Data from this method.
*
* @return Response
*/
public function index()
{
$this->load->library('mylibrary');
echo $this->mylibrary->my_first_call();
}
}
Now you can simply check.
I hope it can help you....

Hardik Savani
I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- PHP Codeigniter get last executed query example
- PHP Codeigniter 3 - Create Dynamic Tree View using Bootstrap Treeview JS
- PHP Codeigniter 3 Google Recaptcha Form Validation Example
- PHP Codeigniter 3 Ajax Pagination using Jquery Example
- How to Create Dynamic Sitemap in PHP Codeigniter?
- Codeigniter 3 Datatables Ajax Example From Scratch
- Codeigniter 3 - Generate PDF from view using dompdf library with example
- Codeigniter 3 - select2 ajax autocomplete from database example with demo