Laravel 5

Laravel 5: Resolving Concrete Implementations From the Service Container With resolve


John Koster

Published on April 14, 2018

The resolve helper function can be used to resolve a class instance form the Service Container. This function is typically used with named instances, but can be used to resolve any dependency from the Service Container as long as its constructor parameter dependencies can be resolved by the Service Container.

The resolve function is similar to the app helper function in that it allows you to resolve dependencies from the Service Container, however, unlike the app helper function, you cannot supply parameters to the Service Container when it is resolving the dependency.


The signature of the resolve function is:

1function resolve(
2 $name

Example Use

The following example will resolve Laravel's event dispatcher from the Service Container:

1// Get the event dispatcher instance.
2$dispatcher = resolve('events');

Explore The Blog