By 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.
#Signature
The signature of the app
function is:
1function app(
2 $abstract = null,
3 array $parameters = []
4);
#Example Use
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 of
2// Illuminate\Auth\AuthManager
3$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');
∎