Welcome Guest, Not a member yet? Register   Sign In
Accsess my Libraries from Models

I'm currently migrating from CI 3 to CI4. How to access my Libraries methods from a Models ? A lot of doc i'had read just show how to access it from a Controller. Any advices please ? 
Sorry for my bad english.

There's no difference in loading a library from a controller or from a model. You can create a new instance of your class the standard PHP way:
PHP Code:
$myLib = new MyLib(); 

Or you can define a service. This allows to get a shared instance if you need to access your library in multiple places, instead of creating a new object everytime.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/

Theme © iAndrew 2016 - Forum software by © MyBB