Welcome Guest, Not a member yet? Register   Sign In
Where to load models, helpers, libraries? Autoload? Constructor? Method?
#4

[eluser]Jelmer[/eluser]
Personally I try to do as much on demand and as little globally as possible. I do almost always load the form and URL helpers through autoload.

I used to place all libraries/helpers/models that a controller needed for most of its function in the constructor (directly after parent::Controller()). And when they were specific to the method I'd place them at the very top of the method before any other code (to make any "dependencies" clear and easy to locate).

But I've switched to using my implementation of another syntax for CI a while ago and now I don't need to load anything before I use it except for Helpers (which I still place in the aforementioned locations).
For example: I'd use Ci::lib('email')->from() instead of first loading the email class. It will try first to give me $this->email. When that fails it loads the email library (using $this->load->library('email')) and then tries again to return $this->email.
(you can find that "syntax" implementation as a helper here)


Messages In This Thread
Where to load models, helpers, libraries? Autoload? Constructor? Method? - by El Forum - 08-09-2010, 08:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB