I am using this autoloader to load multiple external libraries in my zend app. The classes开发者_StackOverflow中文版 are loaded correctly and works fine. But i seem to have an issue while loading classes using multiple such autoloaders. The problem is that after finding the class in one of the autoloaders, zend continues searching in other loaders hence producing the following error message from autoloaders except from the one they are defined in.
Notice: Undefined index: myClassFile in /var/www/myApp/application/loaders/Autoloader/PhpThumb.php on line 21
where myClassFile is defined in another loader and loading/working fine, but it still continues to searching in this second autoloader where its not defined.
Any idea what i am missing ?
Update: my bootstrap file:
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$autoLoader=Zend_Loader_Autoloader::getInstance();
$resourceLoader=new Zend_Loader_Autoloader_Resource(array(
'basePath'=>APPLICATION_PATH,
'namespace'=>'',
'resourceTypes'=>array(
'form'=>array(
'path'=>'forms/',
'namespace'=>'Form_'
),
'models'=>array(
'path'=>'models/',
'namespace'=>'Model_'
),
)
));
//return $autoLoader;
$resourceLoader->addResourceType('loader', 'loaders/', 'My_Loader_');
$autoLoader->pushAutoloader($resourceLoader);
//load PhpThumb class
$autoLoader->pushAutoloader(new My_Loader_Autoloader_PhpThumb());
//load Factory Class
$autoLoader->pushAutoloader(new My_Loader_Autoloader_Factory());
}
}
?>
and later to use it:
$factory=new Factory();
which seem to work fine but throws error.
I might not be able to understand your problem correctly . But If you are trying to autoload external library such as PhpThumb then you are doing it wrong . Since to much autloading will make application slower . In library such as PhpThumb there are hardly One php file simply use require_once instead . And put this path APPLICATION_PATH/library/PhpThumb.php
精彩评论