Zend_Loader

Zend_Loader was the usual kind of autoloading in Zend Framework before version 1.8. Than simply you say:

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

That made all your application to autoload files from the library folder where usualy the Zend Framework stays. That has several things to be changed.

The namespaces

There where not really namespaces for autoloading. Everything was searched to be loaded in one single namespace. And thus there where not the functionality to remove a namespace from the game. You have everything all the time.

Zend_Loader_Autoloader

This is new from version 1.8 in Zend Framework. Now you should use this class to autoload your classes. There’s really namespaces and for more info and detailed information you should search the documentation of the ZF.

The most simple way to switch from Zend_Loader to Zend_Loader_Autoloader

That’s really simple, and I don’t understand why there’s not proper explanation how to do that in the ZF docs. You need to replaces this lines of code:

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

with these:

require_once ‘Zend/Loader/Autoloader.php’;
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);

Related posts:

  1. Zend Framework – quick tutorial (part 2)
  2. Lambda functions in PHP?
  3. Zend Framework custom URLs