How to use a helper function in a controller?

AnNaMaLaI picture AnNaMaLaI · Jun 23, 2011 · Viewed 31.1k times · Source

I wrote some function in app_helper file. now i need to call that function in my controller how i can do this in CAKEPHP

Answer

deceze picture deceze · Jun 23, 2011

You can't.*

If your functions are so universal as to be used outside of views, create them in bootstrap.php or make a custom library/class in the libs/ directory.


* You can load anything anywhere using App::import('Helper', 'NameOfHelper') or ClassRegistry::init, but you really shouldn't. The point of MVC separation is to keep your app well organized.