![]() |
CI 4 - beginner problems - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: CI 4 - beginner problems (/showthread.php?tid=76607) |
CI 4 - beginner problems - boddah85 - 06-01-2020 Hello Im trying to make a switch from CI3 to CI4. I must admit that I really like ci3, however ci4 looks great and I'm looking forward to make an apps with new version o ci. At the beginning, for the testing purspose, I'm trying to write a really simple auth libarary. In CI3 i would create MyAuth in application/library: PHP Code: class MyAuth in controller i could load it PHP Code: public function testing and in view I could print it like that: PHP Code: echo $this->myauth->getName(); Is there any way to do the same in ci 4? Sorry but I can't find many informations about creating libraries in CI 4. Second question: How to check if there's database connection? In CI 3 i checked it this way: PHP Code: $connDB = $this->load->database('default',TRUE); PHP Code: $this->dbSocket = \Config\Database::connect($custom); dbSocket->connID is always false. RE: CI 4 - beginner problems - fujael - 06-01-2020 I guess you're kind of stuck with `load` object to initiate a library. This new CI4 is way better in my opinion to load library. You can load your library class by this > Create a class under `app/Libraries` > Make sure you are using namespace like this PHP Code: <?php PHP Code: $this->libraryName = new App\Libraries\{ClassName}; {The opinion is my own, this is not official} |