Welcome Guest, Not a member yet? Register   Sign In
Autoload idea
#8

(03-22-2016, 07:54 AM)PaulD Wrote: Yes, following Narfs points he is right, it is not a good idea.

An interesting suggestion though Sezu, even if, under scrutiny, it didn't pan out.

Paul.

@Narf
Could you expand a bit on that comment about using $this->something to access a specific type? Or perhaps suggest a link for me to read about it? Thank you.

There's nothing to link to ... it's not something common, just how CI has solved this one particular problem.

It would be very annoying if you had to do a require_once() AND $something = Something($config); every time you wanted to load a library, so someone came up with $this->load->library('something') and $this->load->model('something_model'), each assigning the appropriate class instance to a CI_Controller property.
But that was the easiest way back then, not now.

Today, with PHP's lazy auto-loading, you can just do $something = new Something($param1, $param2); and it's all under your control - no need for a dedicated loader library, no need to use a class property if you don't want to, no limitations about constructor parameters, etc.
Any new auto-loading solutions should be built that way.
Reply


Messages In This Thread
Autoload idea - by Sezu - 03-22-2016, 12:05 AM
RE: Autoload idea - by PaulD - 03-22-2016, 05:25 AM
RE: Autoload idea - by ivantcholakov - 03-22-2016, 05:37 AM
RE: Autoload idea - by Narf - 03-22-2016, 05:39 AM
RE: Autoload idea - by Sezu - 03-22-2016, 07:30 AM
RE: Autoload idea - by PaulD - 03-22-2016, 07:54 AM
RE: Autoload idea - by Narf - 03-22-2016, 08:34 AM
RE: Autoload idea - by Sezu - 03-22-2016, 08:11 AM
RE: Autoload idea - by PaulD - 03-22-2016, 08:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB