0

I am writing my own log class in zendframework based application. I was wondering as it's my own lib class where to keep it in application. I decided to keep this class parallel to "Zend" folder inside /library folder

-library
 - Zend
 - Helper [ custom lib classes]

In bootstrap.php I have _initAutoload function where in I have added following

  $autoloader=new Zend_Loader_Autoloader_Resource(array(
            'basePath'  => dirname(__FILE__),
            'namespace' => 'Demo',
        ));
        $autoloader->addResourceType('model', 'models/', 'Model');
        $autoloader->addResourceType('helper', APPLICATION_PATH.'/library/Helper', 'Helper');

but I get error Demo_Helper_Logger class not found.

Whats could be wrong here? Any idea?

Thanks

Tim Fountain
  • 33,093
  • 5
  • 41
  • 69
user269867
  • 3,266
  • 9
  • 45
  • 65
  • Error is library is parallel to application and with some reason Zend_loader_Autoloader_Resources try n add the '/library/Helper' inside 'application' directory hence I am finding not found error. Anyone know how to autoload external library? – user269867 Sep 06 '12 at 08:38

1 Answers1

1

If you are using ZF 1.9+ you can handle this inside your application.ini

Put your custom "library" into:

../library/Helper/Log.php

Name your class like:

class Helper_Log {}

Add

autoloadernamespaces.1 = "Helper_" 

to your application.ini

$log = new Helper_Log(); 
opHASnoNAME
  • 20,224
  • 26
  • 98
  • 143