![]() |
Classmap not loaded? - 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: Classmap not loaded? (/showthread.php?tid=75315) |
Classmap not loaded? - evansharp - 01-25-2020 Hi board! I am trying to locate a custom library out of `ThirdParty/` using the classmap instead of PSR-4. I have been successful using the PSR-4 namespace autoloader, but as this is my auth library and will be run frequently, I want to realize the performance of the classmap feature. Oauth class (/app/ThirdParty/Googleapi/Oauth.php): Code: <?php namespace ThirdParty\Googleapi; Autoload.php: Code: $psr4 = [ BaseController.php Code: namespace App\Controllers; As this is written, I get `Error: Class 'App\Controllers\Oauth' not found` in BaseController when trying to instantiate the Oauth class. This tells me CI did not check the classmap and instead just looked for `Oauth` in the controller PSR namespace that was loaded. Have I done something wrong or is this a bug? Thanks! Evan RE: Classmap not loaded? - ajmeireles - 02-13-2020 Hey, you is able to understand how it work now? I have same issue! RE: Classmap not loaded? - evansharp - 02-13-2020 (02-13-2020, 10:56 AM)ajmeireles Wrote: Hey, you is able to understand how it work now? I have same issue!Nope, I'm still using namespaces. RE: Classmap not loaded? - jreklund - 02-14-2020 Hi, we discussed this in Codeigniter's slack channel yesterday. And the solution to this are: PHP Code: <?php namespace App\Controllers; If you are just specifying new Oauth() till will look in a relative path e.g. App\Controllers, as you are trying to access it from there. If you want it to load the global Oauth you will need to use "use Oauth" before making the class. |