0

I am using this autoloader to load multiple external libraries in my zend app. The classes 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.

4

1 に答える 1

-2

あなたの問題を正しく理解できないかもしれません。しかし、PhpThumb などの外部ライブラリを自動ロードしようとしている場合は、間違っています。オートローディングが多すぎると、アプリケーションが遅くなるためです。PhpThumb などのライブラリには、ほとんど 1 つの php ファイルがなく、代わりに require_once を使用するだけです。そして、このパスを置きますAPPLICATION_PATH/library/PhpThumb.php

于 2011-09-26T17:59:18.423 に答える