I have a cakephp2 app and the controllers are getting really big. Is there a best practice for breaking out bits of code into other functions that are not supposed to be actions?
*Sorry it has been a looong time since I did this with cakephp1.0 and back then I think I called them _functionname, which seems wrong these days.*
If you controller has been growing uncontrollably, then it has accumulated domain business logic and/or presentation logic.
The solution would be to move domain logic back into model layer. Either put that functionality in
AppModelclasses (which might be problematic, since it uses Active Record (anti)pattern), or create higher order structures, that do not extentAppModeland instead would act as services from proper model layer implementation.And presentation logic should go back into the views (or since you are using the Rails parody of MVC – in the view helpers).