How to create custom library file in codeigniter 3?

How to create custom library file in codeigniter 3?

tutorials -

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.



class Mylibrary {

function my_first_call()


return 'Hello,';




now create one route for testing so let's register one route for calling custom library function.


$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:



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()



echo $this->mylibrary->my_first_call();



Now you can simply check.

I hope it can help you....

Trending On Tutorial Stuff

Our Sponsors

Top Applications in Tutorial Stuff

Top Experts In Tutorial Stuff