Pregunta

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

¿Fue útil?

Solución

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(); 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top