20.2 Resolving Objects
Now we have our disco ball registered, let’s see how we can get it back. Let’s make a call to
resolve.
1 <?php
2 $db = IoC::resolve('discoball');
And that’s it! Instead of creating and configuring a new instance of our discoball each time, we
make a call to the resolve() method, passing the string that identifies the object and the IoC
container will execute the closure we created in the first section, and return our instantiated and
configured discoball object.
Handy, and saves many lines of code!
You can register and resolve as many objects as you want, go ahead and try it. For now lets
move on to singletons.
Yasar Khan
Skills Laravel
Qualifications :-Location :-Dehradun,Dehradun,Uttarakhand,India
Description:- Hi i am yasar working as web developer since last 3 years.
Explore