Welcome Guest, Not a member yet? Register   Sign In
Objects in CI, are they ever used?

Are they? In the controller file, I mean.
I dont see the new operator used much or other objects instantiated. New to CI.

You can write a model or library in instantiate it with the "new className();" method anywhere in CI.

You can see how CI loads packages here too :
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!

Yes, "objects" are used in CI. The loader class (/system/core/loader.php) does instantiation of any class it is asked to load.

A simplified summary of the way CodeIgniter works is that there is a "super object", and the loader class adds new classes as properties of that super object. That's why when you're in a controller and you load a library, you then use it with $this->.

That is one of the fundamental reasons why CI is so easy to use, but also a reason that CI is heavily criticized. "Modern" PHP frameworks will have a totally different kind of autoloading and class usage. There is nothing stopping you from autoloading this way in CI, and depending on the classes you are using, you might have to. When I use a library of some classes that require autoloading, I'll usually use Symfony's PSR4 class autoloader.

Theme © iAndrew 2016 - Forum software by © MyBB