I don’t know how Magento does this (tipp: look at the source code), but you can probably achieve the same Zend_Autoloader, for example, when you try to load a class, the Foo_Bar_Bazautoloader first looks in Local/Foo/Bar/Baz, and if the file is not there, it will try to load from Core/Foo/Bar/Baz.
Note. . If anyone is interested, take a look at the top app/Mage.php(shutter speed) to see how this is set. --Alan
if (defined('COMPILER_INCLUDE_PATH')) {
$appPath = COMPILER_INCLUDE_PATH;
set_include_path($appPath . PS . Mage::registry('original_include_path'));
include_once "Mage_Core_functions.php";
include_once "Varien_Autoload.php";
} else {
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths[] = BP . DS . 'lib';
$appPath = implode(PS, $paths);
set_include_path($appPath . PS . Mage::registry('original_include_path'));
include_once "Mage/Core/functions.php";
include_once "Varien/Autoload.php";
}
source
share