Search code examples
zend-frameworkautoloadzend-autoloaderzend-loaderautoloader

How to upgrade Zend_Loader from 1.7 to 1.8?


I have been using this, and it works fine in 1.7, but not in 1.8.

    require_once('Zend/Loader.php');
    Zend_Loader::registerAutoload();

It says it's deprecated, and that I should use Zend_Loader_Autoloader instead, but I can't seem to get it to work. Any suggestions?


Solution

  • As a bare minimum you'll need to change the code to

    require_once 'Zend/Loader/Autoloader.php';
    $loader = Zend_Loader_Autoloader::getInstance();
    

    If you have some code that is not namespaced, like models, you'll need this too:

    $loader->setFallbackAutoloader(true);
    

    More details at http://akrabat.com/2009/04/30/zend_loaders-autoloader_deprecated-in-zend-framework-18/