phpzend-frameworkzend-autoloader

zend auto loader... custom classes. How do I get it to work?


I am looking to create my own collection of class files in the library/common folder

/library/common/*class files go in here*

Inside the folder I will have various class files that I want to make available

such as

DecoratorSimple.php

example of the code can be seen below?

class Common_Decorator_SimpleInput extends Zend_Form_Decorator_Abstract
{
  // code goes in here
}

The question I have is how do I get the zend application to automatically load anything in common folder that has the the prefix of Common_

I have tried adding the following to the bootstrap but it did not work

protected function _initTestAutoLoader(){

    $autoloader = Zend_Loader_Autoloader::getInstance();
    $autoloader->registerNamespace('Common_');

    // try and load the class
    $testVar = new Common_Decorator_SimpleInput();
    var_dump($test);
}

Solution

  • Is your class name matching the library path...
    eg Common_Decorator_SimpleInput
    must be in /library/Common/Decorator/SimpleInput.php