Contao\ClassLoader::scanAndRegister PHP Method

scanAndRegister() public static method

Scan the module directories for config/autoload.php files and then register the autoloader on the SPL stack
public static scanAndRegister ( )
    public static function scanAndRegister()
    {
        $strCacheDir = \System::getContainer()->getParameter('kernel.cache_dir');
        // Try to load from cache
        if (file_exists($strCacheDir . '/contao/config/autoload.php')) {
            include $strCacheDir . '/contao/config/autoload.php';
        } else {
            try {
                $files = \System::getContainer()->get('contao.resource_locator')->locate('config/autoload.php', null, false);
            } catch (\InvalidArgumentException $e) {
                $files = array();
            }
            foreach ($files as $file) {
                include $file;
            }
        }
        self::register();
    }

Usage Example

 /**
  * Initializes the framework.
  */
 private function initializeFramework()
 {
     // Set the error_reporting level
     error_reporting($this->errorLevel);
     $this->includeHelpers();
     // TODO: use Monolog to log errors
     $this->iniSet('error_log', $this->rootDir . '/system/logs/error.log');
     $this->includeBasicClasses();
     // Set the container
     System::setContainer($this->container);
     // Preload the configuration (see #5872)
     $this->config->preload();
     // Register the class loader
     ClassLoader::scanAndRegister();
     $this->initializeLegacySessionAccess();
     $this->setDefaultLanguage();
     // Fully load the configuration
     $this->config->initialize();
     $this->validateInstallation();
     Input::initialize();
     $this->setTimezone();
     // Set the mbstring encoding
     if (USE_MBSTRING && function_exists('mb_regex_encoding')) {
         mb_regex_encoding($this->config->get('characterSet'));
     }
     $this->triggerInitializeSystemHook();
     $this->handleRequestToken();
 }
All Usage Examples Of Contao\ClassLoader::scanAndRegister