Welcome Guest, Not a member yet? Register   Sign In
Classmap not loaded?

(This post was last modified: 01-25-2020, 02:37 PM by evansharp.)

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):
<?php namespace ThirdParty\Googleapi;

class Oauth
    public function __construct()


    public function dance(){
        return "dance dance baby!";


$psr4 = [
       'Config'          => APPPATH . 'Config',
       APP_NAMESPACE     => APPPATH,                // For custom namespace
       'App'             => APPPATH,                // To ensure filters, etc still found,

       //'ThirdParty'      => APPPATH . 'ThirdParty'  // temporarily disable PSR to test classmap locating

    $classmap = [
       'Oauth'        => APPPATH . 'ThirdParty/Googleapi/Oauth.php'

namespace App\Controllers;

use CodeIgniter\Controller;
//use ThirdParty\Googleapi\Oauth; // temporarily disable PSR to test classmap locating

class BaseController extends Controller

    protected $helpers = [];

    public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
        // Do Not Edit This Line
        parent::initController($request, $response, $logger);

        $this->googleapi = new Oauth();


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?


Messages In This Thread
Classmap not loaded? - by evansharp - 01-25-2020, 02:35 PM
RE: Classmap not loaded? - by ajmeireles - 02-13-2020, 10:56 AM
RE: Classmap not loaded? - by evansharp - 02-13-2020, 07:21 PM
RE: Classmap not loaded? - by jreklund - 02-14-2020, 12:12 PM

Theme © iAndrew 2016 - Forum software by © MyBB