April 14, 2018 —John Koster
The app
function provides access to the "Illuminate\Container\Container" instance. Because Container
is a singleton, any call to app()
will return the same Container
instance. The app
function can also be used to resolve registered dependencies from the Service Container instance.
The signature of the app
function is:
1function app(2 $abstract = null,3 array $parameters = []4);
For example, to return an instance of the "Illuminate\Auth\AuthManager" class (the class behind the Auth
facade), invoke app
with the auth
argument:
1// $authManager will be an instance of2// Illuminate\Auth\AuthManager3$authManager = app('auth');
The previous example would be equivalent to resolving the Service Container itself and invoking the make
method:
1$authManager = app()->make('auth');
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.