Now, let's see article of make custom library in codeigniter. This article goes in detailed on codeigniter 3 load custom library example. In this article, we will implement a create custom library file in codeigniter. This tutorial will give you simple example of codeigniter custom library example. You just need to some step to done create custom library in codeigniter.
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, HDTuto.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....
Do you like below Tutorials ?
- Laravel 7.x and 6.x Ajax Multiple Image Upload with Preview Example
- Laravel select with count(*) using db raw example
- PHP Laravel select with join subquery example
- PHP Laravel Ajax Form Submit Example
- How to create events for created/updated/deleted model task in Laravel 5?
- Angular JS Form Validation Example Code
- AngularJS - Confirm Password Validation Example
- Laravel Ajax Request using X-editable bootstrap Plugin Example