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 ?
2 Answers
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.

- 13,282
- 10
- 43
- 60
-
how can I extend core classes ? – Vivek Goel Apr 13 '11 at 13:47
-
1@Vivek Goel: `class HTML extends Kohana_HTML` would extend the core Kohana HTML class. – David Hancock Apr 13 '11 at 13:59
-
Thanks, Kohana still does not have a valuable documentation for the new versions. – Rolice Apr 06 '12 at 07:34