I am following documentation http://docs.kohanaphp.com/general/helpers . But these steps are not working in kohana 3.1 . I can't find any documentation about helper in kohana 3.1 开发者_开发知识库. how I can create my own helper class in kohana ?
The accepted answer isn't really true!
Helpers do exist in Kohana 3.1.
http://kohanaframework.org/3.1/guide/kohana/helpers
Helpers are different from libraries in that they use static methods, the class does not have to be initiated for them to be used.
i.e. to call the URL helper class and run the base method you would simply do:
$foo = URL::base();
To extend the URL helper you would create a class in APPPATH/application/classes/
called url.php
like:
class URL extends Kohana_URL {
public static function bar()
{
// Do your magic
}
}
And then again simply call it like so:
$foo = URL::bar();
There's no such thing as a helper in Kohana 3/3.1
You create a class and use it as you normally would in a PHP application.
The only requirements are that classes go into the classes
directory and underscores in the class name are equal to directory separators. For example
class HTML_Helper
would be placed into
classes/html/helper.php
Then it's a simple case of using the class as your normally would.
精彩评论