Sometimes, we might be required to make a custom library in the Codeigniter project. However, we can load the custom library quickly and use that functions.

Let's create a library file in the libraries folder of your app.


class Mylibrary {
  function my_first_call()

  // you can add any functionality here
    return 'Hello world!';

Now let's create a controller and call the created custom library in Codeigniter


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

then register route and see the output



$route['my-library'] = "MyLibraryController";

Thanks, it will work for you.......