Welcome Guest, Not a member yet? Register   Sign In
Return autoload.

Return autoload.
In ci3 it was convenient. config/autoload.php

$autoload['libraries'] = array('test_lib');

Projects often use the same libraries and helpers.
Starting to write a controller with a bunch of new \ App \ Libraries \ MyLib is funny.
It’s stupid to do BaseController from which to use all other controllers for their use.
I think the idea of autoloading libraries and helpers in Ci3 was wonderful.
Or just explain how easier it is to work with libraries and helpers that are used constantly in the application.

"Make it idiot proof and someone will make a better idiot."

@kierownik That is what CI4 does, with the conventional interpretation of the term "autoloader", but that is different from the CI3 "autoload" capability that the OP refers to.

@ramstudio CI4 does not have an app or controller super-object like CI3 did, which could have any number of things injected "magically", and propagated to loaded models. Making a base controller and instantiating models & libraries inside it, the "CI4 way", would help a bit - minimal inconvenience, but those properties would not be available to models or other classes.

I am not sure how practical or advisable it would be, but you could add static properties in app/Config/App, initializing them in a constructor. The result would then be "App::banana" instead of "$this->banana" (where banana is something you would have "autoloaded" in CI3). And these would be accessible anywhere inside your app.

Not sure if I am on the right track here - we'll see how this gets shot down by the community Undecided

@ramstudio $x = new \App\Libraries\MyLib; is funny.
I think $this->load('foo'); is dorky.

type in a "use "\App\Libraries\MyLib;" statement and you can use "$x = new MyLib();"
This is the modern way of doing things in PHP.
Simpler is always better

Yes, I guess I got excited.
Startup is great, just a little getting used to.
And in general is very nice that being good documentation.

Theme © iAndrew 2016 - Forum software by © MyBB