I'm relatively new to CodeIgniter, and so far my project is created entirely using Controllers and Views. However, as it's getting more complex, I'm finding that there are certain functions that I've copy-pasted into multiple controllers -- this is hardly ideal as editing one requires remembering to edit all of the others as well.
There is a plethora of CI features that I know nothing about - models, helpers, extending "Controller", etc. etc. Where should I look to in order to accomplish the above? I suppose I could also import()
a block of code directly, although I get the feeling that this is not "the CodeIgniter Way".
Put all your "utility" functions into a "helper manager" and access that.
http://codeigniter.com/user_guide/general/helpers.html
Or create a base controller, and extend other controllers from it.
I'm sure Phil Sturgeon has a guide on it: http://philsturgeon.co.uk/blog/2010/02/CodeIgniter-Base-Classes-Keeping-it-DRY
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With