Return autoload. |
Return autoload.
In ci3 it was convenient. config/autoload.php Code: $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.
https://codeigniter4.github.io/CodeIgnit...oader.html
"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
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. |
Welcome Guest, Not a member yet? Register Sign In |