Autoload Library |
Hi,
I try run autoload Library In autoload file /Config/Autoload.php I use this $classmap = [ 'User' => APPPATH . 'libraries/user.php' ]; and I want auto run this class like CI3 $this->load->library('User'); In CI3 this class run automatically constructor, how to do this in CI4? I new in CI4 (11-10-2017, 01:19 PM)Vykintas Wrote: Hi, You new in PHP. I suggest that you learn a bit more about classes and objects first, after which you wouldn't be asking this question.
put User.php in the Libraries folder and invoke it with $user = new \App\Libraries\User(); Have to learn namespaces for CI4.
Simpler is always better
Ok, I'll ask you more simply
on CI3 automatically load library I just add this in autoload.php $this->load->library('User'); and in controller i can call User library methods like $this->user->getId(); How do This on CI4?
There is no $this->load->library(). CI4 doesn't work this way anymore. There's an Autoload.php config file but it works differently. It uses class mapping and name spaces. It's much less dorky(more modern) than calling $this->load->library().
Simpler is always better
I hope this would help
https://bcit-ci.github.io/CodeIgniter4/c...oader.html
love codeigniter
Learning best practices Rate my post if you found it helpfull |
Welcome Guest, Not a member yet? Register Sign In |