Zend Framework: Autoloading a Class Library

拥有回忆 提交于 2019-11-29 00:00:33

You class needs to be name Me_Myclass:

class Me_Myclass
{
}

Move your library folder up a level so that you have the folder structure:

/
    /application
    /library
    /public

And then in your Bootstrap add the following to the _initAutoload():

    Zend_Loader_Autoloader::getInstance()->registerNamespace('Me_');

you can define the autoload dir in the config.ini file like this:

autoloaderNamespaces[] = "Me_"


;You could add as many as you want Classes dir:
autoloaderNamespaces[] = "Another_"
autoloaderNamespaces[] = "Third_"

works 100%

I think @smack0007 means replace the contents of your _initAutoload method with Zend_Loader_Autoloader::getInstance()->registerNamespace('Me_'); so it looks like this:

protected function _initAutoload()
{
    Zend_Loader_Autoloader::getInstance()->registerNamespace('Me_');
}

Not sure if this is your problem, but I just spent the last day and half trying to figure out my own similar problem (first time loading it up on Linux from Windows). Turns out I was blind to my library's folder name case.

/library
    /Tlib

is not the same as (on *nix)

/library
    /tlib

Class name is typically this

class Tlib_FooMe {
 ...
}

Hope this helps someone who is similarly absentminded.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!