Laravel Classroom
PRADEEP JOSHI /
Professional /
Web Technology
To post your Question Join Classroom
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.
PRADEEP JOSHI
Skills Laravel
Qualifications :-Location :-Yamuna Colony,Dehradun,Uttarakhand,India
Description:-
Explore