Welcome Guest, Not a member yet? Register   Sign In

Hello again Smile

Someone here can give some advice kind of light resume about what is it ?, why and how ?

thanks again.

The get instance just returns a reference to the CI object which contains all the CI settings and objects (tons of stuff). As far as I know you only need to get a reference to the object when you are working in your own classes (referred to as libraries). If your in a model, view or controller you can access the values in the CI object without getting a reference (instance).

Do a web search on the registry design pattern. The user_guide refers to it as the CI super object, but it is referred to as the registry in either common.php or codeigniter.php. A registry object stores any number of objects and variables, allowing them to be accessed globally within an application.

The Front Controller instantiates an instance of the registry when a user accesses your site.

You also need to get a reference when you need to access objects or variables in the registry from a plugin or helper. For example and among other things, you need to get a reference when accessing the database object (dbo) from a helper.

The get_instance also implies it is using the singleton pattern to persist the object (global variable/object)

Theme © iAndrew 2016 - Forum software by © MyBB