0
votes

I've deleted every Zend Framework class in the folder "library/Zend", I used the 1.7 version and wanted to upgrade to 1.12. After the deletion I've uploaded the Zend Framework 1.12 classes in "library/Zend".

I'm facing an issue in loading the classes. In "public/index.php" I used registerAutoload(). This was depricated so I changed it to this:

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

Then, for each class I use in the Controller I have to manually add it like this:

$loader->registerNamespace('Paths');
$loader->registerNamespace('Certificate');
$loader->registerNamespace('Zim_Properties');
$loader->registerNamespace('Zim_Controller_Dispatcher');
$loader->registerNamespace('Controller_Plugin_ActionSetup');
$loader->registerNamespace('Controller_Plugin_History');
$loader->registerNamespace('Zim_Model');
$loader->registerNamespace('Zim_Controller_Action');
$loader->registerNamespace('Controller_ProposalInvoice');
$loader->registerNamespace('Stats');
$loader->registerNamespace('Controller_ArticleService');

If I remove this registerNamespace I get an Fatal error: Class 'Controller_ArticleService' not found in /home/juliaxd8/domains/jmediatechnology.eu/public_html/factuurtogo2/application/controllers/ArticleController.php on line 3

Because of the manually registration I could forgot something/make a typo. Can I do auto load classes?

1
See stackoverflow.com/a/10257309/131824. It notes the distinction between standard classes whose files probably need to reside on the include_path (like your Zim_* classes) and those that reside in the appnamespace (typically, Application_) that need to be handled via a special resource autoloader. - David Weinraub

1 Answers

0
votes

I have a function somewhat like this in the Bootstrap.php file in one of my projects, that I think does the trick:

    protected function _initAutoload()
    {

        $modelLoader = new Zend_Application_Module_Autoloader(
            array('namespace' => '',
                'basePath' => APPLICATION_PATH . '/modules/default'));
        return $modelLoader;
    }