CodeIgniter Forums
CodeIgniter4 AutoLoad Library & Access Across App - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: CodeIgniter4 AutoLoad Library & Access Across App (/showthread.php?tid=76715)



CodeIgniter4 AutoLoad Library & Access Across App - xGuRux - 06-12-2020

Hi Everyone

So i tried a few things i am not able to achieve what i exactly want so let me created this post, let me explain.

So basically i created a Custom Library Pagination (app\Libraries\Pagination\Pagination.php) 

Code:
<?php namespace App\Libraries\Pagination;
class Pagination{


To use this in my controller i did the following 

Code:
use \App\Libraries\Pagination\Pagination;
$pagination = new Pagination();


And it works.

but my problem is if i want to access this class in My Model i need to initialize this again or pass this class to the method.

i would like to know if it would be possible to maybe load this library in Autoload and make it accessible across application. without initializing it again?