Class not found exception - Making a Helper on Kohana 3.1

强颜欢笑 提交于 2019-12-07 16:29:13

问题


got a fresh install of Kohana 3.1. Trying to make my own helpers. I have created a helper in the application/classes/helpers/ directory. I have called the file javascript.php, the class is called Helper_Javascript and has a static function that just returns "alert('sometext')" here it is

class Helper_Javascript {
    public static function alert($message)
    {
        return "alert('$message');\n";
    }
}

The problem is in my view or controller when I try to use the helper i just kepp getting the Class not found exception. I have tried to call it via <?php echo Helper_Javascript::alert('asdf');?> but get:

ErrorException [ Fatal Error ]: Class 'Helper_Javascript' not found. 

Please help, I have tried to read the docs for this at http://www.dealtaker.com/blog/2010/03/26/kohana-php-3-0-ko3-tutorial-part-7/ but it doesnt work.

You can see my view here: http://nabilboag.dyndns.org/simplysweet/


回答1:


The "_" in the class name is used to represent the directory structure. You have the rename the directory "helpers" into "helper": application/classes/helper/



来源:https://stackoverflow.com/questions/5524119/class-not-found-exception-making-a-helper-on-kohana-3-1

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