Hello,
I'm still quite new to CodeIgniter and I was wondering, where should I place my PHP functions that has nothing to do with Controllers and Views, for example, a function that access a local file.
Thank you.
Hello,
I'm still quite new to CodeIgniter and I was wondering, where should I place my PHP functions that has nothing to do with Controllers and Views, for example, a function that access a local file.
Thank you.
You should place them in Controller, in controller you can put in even your own custom functions.
There are plugins and helpers directories where you can place files that include 'global' functions that are shared across your entire application.
That said, you should think before doing this, it may well make more sense to place the file in a model, if you are working with data stored on the file system.
Do not use plugins as they are removed from CI 2.0 and you will have to convert them.
A group of functions that do not require data interaction should be placed in a helper.
Put loose functions into helpers. Group similar functions together into a helper and give it a meaningful file-name. Once the helper is loaded the functions can be used as though it were a require_once() or include.
If you have a class which has ostensibly "nothing to do" with Codeigniter, these can usually be converted into libraries with minimal or no effort.
Plugins are being taken out in CI 2.0, as Phil Sturgeon said, in favour of helpers and libraries. Which is a good thing, I think. Never had much need for 'plugins'.