Search code examples
phpzend-frameworkzend-autoloader

Why these 2 lines in Zend Bootstrap autoloading function


I've seen examples that has this block of code and other examples that didn't have the 2 lines commented MAYBE NOT. What exactly is the purpose of these 2 lines?

$moduleLoader = new Zend_Application_Module_Autoloader(array(
    'namespace' => '',
    'basePath' => APPLICATION_PATH)
);


$autoloader = Zend_Loader_Autoloader::getInstance(); //MAYBE NOT
$autoloader->setFallbackAutoloader(true);      //MAYBE NOT

return $moduleLoader;

Added:

given the answers, is it a good thing to do it this way? Is there overhead or anything that's not good about it, or is this the standard practice?


Solution

  • The second line is kind of workaround for cases when standard structure autoloader is not enough, and should be avoided, because it slows things down (even if sometimes it is very handy).

    Looks like the fallback autoloader will not be available in ZF 2.0.