I have some "global" functions not directly related to a model that need to be called from different controllers. Where can i put them and how can they be correctly called from a controller?
3 Answers
It depends on what your functions do. CakePHP has two generic classes: AppController and AppModel. Every controller should extend AppController and every model should extend AppModel so the methods in these to classes should be available to you in every controller.
Another alternative is to package the functions as behaviors and have all models actAs them.
Depending on semantics you may want to choose one over the other options.
Comments
I would like to suggest you to create your own helper class if you want to use in views OR create your own component to use in controllers.
And group the related function in a single and give a meaningful name.
Such that you can use it in your any project just by copying them to your project.
Just add those files to your code wherever required by using the global array var $helpers = array('your_helper1','helper2'); and for components you can use var $components = array('your_component1','component2');