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.
Anil Bist
Skills Laravel
Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-
I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore