How to create custom library file in codeigniter 3?
In this post we will give you information about How to create custom library file in codeigniter 3?. Hear we will give you detail about How to create custom library file in codeigniter 3?And how to use it also give you demo for it if it is necessary.
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….
Hope this code and post will helped you for implement How to create custom library file in codeigniter 3?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs