class Application extends Container implements HttpKernelInterface, TerminableInterface, ResponsePreparerInterface (View source)

Constants

VERSION

The Laravel framework version.

Properties

protected array $resolved An array of the types that have been resolved. from Container
protected array $bindings The container's bindings. from Container
protected array $instances The container's shared instances. from Container
protected array $aliases The registered type aliases. from Container
protected array $reboundCallbacks All of the registered rebound callbacks. from Container
protected array $resolvingCallbacks All of the registered resolving callbacks. from Container
protected array $globalResolvingCallbacks All of the global resolving callbacks. from Container
protected bool $booted Indicates if the application has "booted".
protected array $bootingCallbacks The array of booting callbacks.
protected array $bootedCallbacks The array of booted callbacks.
protected array $finishCallbacks The array of finish callbacks.
protected array $shutdownCallbacks The array of shutdown callbacks.
protected array $middlewares All of the developer defined middlewares.
protected array $serviceProviders All of the registered service providers.
protected array $loadedProviders The names of the loaded service providers.
protected array $deferredServices The deferred services and their providers.
static protected string $requestClass The request class used by the application.

Methods

bool
resolvable(string $abstract)

Determine if a given string is resolvable.

from Container
bool
bound(string $abstract)

Determine if the given abstract type has been bound.

bool
resolved(string $abstract)

Determine if the given abstract type has been resolved.

from Container
bool
isAlias(string $name)

Determine if a given string is an alias.

from Container
void
bind(string|array $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding with the container.

from Container
getClosure(string $abstract, string $concrete)

Get the Closure to be used when building a type.

from Container
void
bindIf(string $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding if it hasn't already been registered.

from Container
void
singleton(string $abstract, Closure|string|null $concrete = null)

Register a shared binding in the container.

from Container
share(Closure $closure)

Wrap a Closure such that it is shared.

from Container
void
bindShared(string $abstract, Closure $closure)

Bind a shared Closure into the container.

from Container
void
extend(string $abstract, Closure $closure)

"Extend" an abstract type in the container.

getExtender(string $abstract, Closure $closure)

Get an extender Closure for resolving a type.

from Container
void
instance(string $abstract, mixed $instance)

Register an existing instance as shared in the container.

from Container
void
alias(string $abstract, string $alias)

Alias a type to a shorter name.

from Container
array
extractAlias(array $definition)

Extract the type and alias from a given definition.

from Container
mixed
rebinding(string $abstract, Closure $callback)

Bind a new callback to an abstract's rebind event.

from Container
mixed
refresh(string $abstract, mixed $target, string $method)

Refresh an instance on the given target and method.

from Container
void
rebound(string $abstract)

Fire the "rebound" callbacks for the given abstract type.

from Container
array
getReboundCallbacks(string $abstract)

Get the rebound callbacks for a given type.

from Container
mixed
make(string $abstract, array $parameters = array())

Resolve the given type from the container.

mixed
getConcrete(string $abstract)

Get the concrete type for a given abstract.

from Container
bool
missingLeadingSlash(string $abstract)

Determine if the given abstract has a leading slash.

from Container
mixed
build(string $concrete, array $parameters = array())

Instantiate a concrete instance of the given type.

from Container
array
getDependencies(array $parameters, array $primitives = array())

Resolve all of the dependencies from the ReflectionParameters.

from Container
mixed
resolveNonClass(ReflectionParameter $parameter)

Resolve a non-class hinted dependency.

from Container
mixed
resolveClass(ReflectionParameter $parameter)

Resolve a class based dependency from the container.

from Container
array
keyParametersByArgument(array $dependencies, array $parameters)

If extra parameters are passed by numeric ID, rekey them by argument name.

from Container
void
resolving(string $abstract, Closure $callback)

Register a new resolving callback.

from Container
void
resolvingAny(Closure $callback)

Register a new resolving callback for all types.

from Container
void
fireResolvingCallbacks(string $abstract, mixed $object)

Fire all of the resolving callbacks.

from Container
fireCallbackArray(mixed $object, array $callbacks)

Fire an array of callbacks with an object.

from Container
bool
isShared(string $abstract)

Determine if a given type is shared.

from Container
bool
isBuildable(mixed $concrete, string $abstract)

Determine if the given concrete is buildable.

from Container
string
getAlias(string $abstract)

Get the alias for an abstract if available.

from Container
array
getBindings()

Get the container's bindings.

from Container
void
dropStaleInstances(string $abstract)

Drop all of the stale instances and aliases.

from Container
void
forgetInstance(string $abstract)

Remove a resolved instance from the instance cache.

from Container
void
forgetInstances()

Clear all of the instances from the container.

from Container
bool
offsetExists(string $key)

Determine if a given offset exists.

from Container
mixed
offsetGet(string $key)

Get the value at a given offset.

from Container
void
offsetSet(string $key, mixed $value)

Set the value at a given offset.

from Container
void
offsetUnset(string $key)

Unset the value at a given offset.

from Container
mixed
__get(string $key)

Dynamically access container services.

from Container
void
__set(string $key, mixed $value)

Dynamically set container services.

from Container
void
__construct(Request $request = null)

Create a new Illuminate application instance.

createNewRequest()

Create a new request instance from the request class.

void
registerBaseBindings(Request $request)

Register the basic bindings into the container.

void
registerBaseServiceProviders()

Register all of the base service providers.

void
registerExceptionProvider()

Register the exception service provider.

void
registerRoutingProvider()

Register the routing service provider.

void
registerEventProvider()

Register the event service provider.

void
bindInstallPaths(array $paths)

Bind the installation paths to the application.

static string
getBootstrapFile()

Get the application bootstrap file.

void
startExceptionHandling()

Start the exception handling for the request.

string
environment()

Get or check the current application environment.

bool
isLocal()

Determine if application is in local environment.

string
detectEnvironment(array|string $envs)

Detect the application's current environment.

bool
runningInConsole()

Determine if we are running in the console.

bool
runningUnitTests()

Determine if we are running unit tests.

forceRegister(ServiceProvider|string $provider, array $options = array())

Force register a service provider with the application.

register(ServiceProvider|string $provider, array $options = array(), bool $force = false)

Register a service provider with the application.

getRegistered(ServiceProvider|string $provider)

Get the registered service provider instance if it exists.

resolveProviderClass(string $provider)

Resolve a service provider instance from the class name.

void
markAsRegistered(ServiceProvider $provider)

Mark the given provider as registered.

void
loadDeferredProviders()

Load and boot all of the remaining deferred providers.

void
loadDeferredProvider(string $service)

Load the provider for a deferred service.

void
registerDeferredProvider(string $provider, string $service = null)

Register a deferred provider and service.

void
before(Closure|string $callback)

Register a "before" application filter.

void
after(Closure|string $callback)

Register an "after" application filter.

void
finish(Closure|string $callback)

Register a "finish" application filter.

void
shutdown(callable $callback = null)

Register a "shutdown" callback.

void
useArraySessions(Closure $callback)

Register a function for determining when to use array sessions.

bool
isBooted()

Determine if the application has booted.

void
boot()

Boot the application's service providers.

void
bootApplication()

Boot the application and fire app callbacks.

void
booting(mixed $callback)

Register a new boot listener.

void
booted(mixed $callback)

Register a new "booted" listener.

void
run(Request $request = null)

Run the application and send the response.

HttpKernelInterface
getStackedClient()

Get the stacked HTTP kernel for the application.

void
mergeCustomMiddlewares(Builder $stack)

Merge the developer defined middlewares onto the stack.

void
registerBaseMiddlewares()

Register the default, but optional middlewares.

$this
middleware(string $class, array $parameters = array())

Add a HttpKernel middleware onto the stack.

void
forgetMiddleware(string $class)

Remove a custom middleware from the application.

Response
handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true)

Handle the given request and get the response.

Response
dispatch(Request $request)

Handle the given request and get the response.

void
terminate(Request $request, Response $response)

Call the "finish" and "shutdown" callbacks assigned to the application.

void
refreshRequest(Request $request)

Refresh the bound request instance in the container.

void
callFinishCallbacks(Request $request, Response $response)

Call the "finish" callbacks assigned to the application.

void
fireAppCallbacks(array $callbacks)

Call the booting callbacks for the application.

prepareRequest(Request $request)

Prepare the request by injecting any services.

Response
prepareResponse(mixed $value)

Prepare the given value as a Response object.

bool
readyForResponses()

Determine if the application is ready for responses.

bool
isDownForMaintenance()

Determine if the application is currently down for maintenance.

void
down(Closure $callback)

Register a maintenance mode event listener.

void
abort(int $code, string $message = '', array $headers = array())

Throw an HttpException with the given data.

void
missing(Closure $callback)

Register a 404 error handler.

void
error(Closure $callback)

Register an application error handler.

void
pushError(Closure $callback)

Register an error handler at the bottom of the stack.

void
fatal(Closure $callback)

Register an error handler for fatal errors.

getConfigLoader()

Get the configuration loader instance.

getEnvironmentVariablesLoader()

Get the environment variables loader instance.

getProviderRepository()

Get the service provider repository instance.

array
getLoadedProviders()

Get the service providers that have been loaded.

void
setDeferredServices(array $services)

Set the application's deferred services.

bool
isDeferredService(string $service)

Determine if the given service is a deferred service.

static string
requestClass(string $class = null)

Get or set the request class for the application.

void
setRequestForConsoleEnvironment()

Set the application request for the console environment.

static mixed
onRequest(string $method, array $parameters = array())

Call a method on the default request class.

string
getLocale()

Get the current application locale.

void
setLocale(string $locale)

Set the current application locale.

void
registerCoreContainerAliases()

Register the core class aliases in the container.

Details

protected bool resolvable(string $abstract)

Determine if a given string is resolvable.

Parameters

string $abstract

Return Value

bool

bool bound(string $abstract)

Determine if the given abstract type has been bound.

(Overriding Container::bound)

Parameters

string $abstract

Return Value

bool

bool resolved(string $abstract)

Determine if the given abstract type has been resolved.

Parameters

string $abstract

Return Value

bool

bool isAlias(string $name)

Determine if a given string is an alias.

Parameters

string $name

Return Value

bool

void bind(string|array $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding with the container.

Parameters

string|array $abstract
Closure|string|null $concrete
bool $shared

Return Value

void

protected Closure getClosure(string $abstract, string $concrete)

Get the Closure to be used when building a type.

Parameters

string $abstract
string $concrete

Return Value

Closure

void bindIf(string $abstract, Closure|string|null $concrete = null, bool $shared = false)

Register a binding if it hasn't already been registered.

Parameters

string $abstract
Closure|string|null $concrete
bool $shared

Return Value

void

void singleton(string $abstract, Closure|string|null $concrete = null)

Register a shared binding in the container.

Parameters

string $abstract
Closure|string|null $concrete

Return Value

void

Closure share(Closure $closure)

Wrap a Closure such that it is shared.

Parameters

Closure $closure

Return Value

Closure

void bindShared(string $abstract, Closure $closure)

Bind a shared Closure into the container.

Parameters

string $abstract
Closure $closure

Return Value

void

void extend(string $abstract, Closure $closure)

"Extend" an abstract type in the container.

(Overriding Container::extend)

Parameters

string $abstract
Closure $closure

Return Value

void

Exceptions

InvalidArgumentException

protected Closure getExtender(string $abstract, Closure $closure)

Get an extender Closure for resolving a type.

Parameters

string $abstract
Closure $closure

Return Value

Closure

void instance(string $abstract, mixed $instance)

Register an existing instance as shared in the container.

Parameters

string $abstract
mixed $instance

Return Value

void

void alias(string $abstract, string $alias)

Alias a type to a shorter name.

Parameters

string $abstract
string $alias

Return Value

void

protected array extractAlias(array $definition)

Extract the type and alias from a given definition.

Parameters

array $definition

Return Value

array

mixed rebinding(string $abstract, Closure $callback)

Bind a new callback to an abstract's rebind event.

Parameters

string $abstract
Closure $callback

Return Value

mixed

mixed refresh(string $abstract, mixed $target, string $method)

Refresh an instance on the given target and method.

Parameters

string $abstract
mixed $target
string $method

Return Value

mixed

protected void rebound(string $abstract)

Fire the "rebound" callbacks for the given abstract type.

Parameters

string $abstract

Return Value

void

protected array getReboundCallbacks(string $abstract)

Get the rebound callbacks for a given type.

Parameters

string $abstract

Return Value

array

mixed make(string $abstract, array $parameters = array())

Resolve the given type from the container.

(Overriding Container::make)

Parameters

string $abstract
array $parameters

Return Value

mixed

protected mixed getConcrete(string $abstract)

Get the concrete type for a given abstract.

Parameters

string $abstract

Return Value

mixed $concrete

protected bool missingLeadingSlash(string $abstract)

Determine if the given abstract has a leading slash.

Parameters

string $abstract

Return Value

bool

mixed build(string $concrete, array $parameters = array())

Instantiate a concrete instance of the given type.

Parameters

string $concrete
array $parameters

Return Value

mixed

Exceptions

BindingResolutionException

protected array getDependencies(array $parameters, array $primitives = array())

Resolve all of the dependencies from the ReflectionParameters.

Parameters

array $parameters
array $primitives

Return Value

array

protected mixed resolveNonClass(ReflectionParameter $parameter)

Resolve a non-class hinted dependency.

Parameters

ReflectionParameter $parameter

Return Value

mixed

Exceptions

BindingResolutionException

protected mixed resolveClass(ReflectionParameter $parameter)

Resolve a class based dependency from the container.

Parameters

ReflectionParameter $parameter

Return Value

mixed

Exceptions

BindingResolutionException

protected array keyParametersByArgument(array $dependencies, array $parameters)

If extra parameters are passed by numeric ID, rekey them by argument name.

Parameters

array $dependencies
array $parameters

Return Value

array

void resolving(string $abstract, Closure $callback)

Register a new resolving callback.

Parameters

string $abstract
Closure $callback

Return Value

void

void resolvingAny(Closure $callback)

Register a new resolving callback for all types.

Parameters

Closure $callback

Return Value

void

protected void fireResolvingCallbacks(string $abstract, mixed $object)

Fire all of the resolving callbacks.

Parameters

string $abstract
mixed $object

Return Value

void

protected fireCallbackArray(mixed $object, array $callbacks)

Fire an array of callbacks with an object.

Parameters

mixed $object
array $callbacks

bool isShared(string $abstract)

Determine if a given type is shared.

Parameters

string $abstract

Return Value

bool

protected bool isBuildable(mixed $concrete, string $abstract)

Determine if the given concrete is buildable.

Parameters

mixed $concrete
string $abstract

Return Value

bool

protected string getAlias(string $abstract)

Get the alias for an abstract if available.

Parameters

string $abstract

Return Value

string

array getBindings()

Get the container's bindings.

Return Value

array

protected void dropStaleInstances(string $abstract)

Drop all of the stale instances and aliases.

Parameters

string $abstract

Return Value

void

void forgetInstance(string $abstract)

Remove a resolved instance from the instance cache.

Parameters

string $abstract

Return Value

void

void forgetInstances()

Clear all of the instances from the container.

Return Value

void

bool offsetExists(string $key)

Determine if a given offset exists.

Parameters

string $key

Return Value

bool

mixed offsetGet(string $key)

Get the value at a given offset.

Parameters

string $key

Return Value

mixed

void offsetSet(string $key, mixed $value)

Set the value at a given offset.

Parameters

string $key
mixed $value

Return Value

void

void offsetUnset(string $key)

Unset the value at a given offset.

Parameters

string $key

Return Value

void

mixed __get(string $key)

Dynamically access container services.

Parameters

string $key

Return Value

mixed

void __set(string $key, mixed $value)

Dynamically set container services.

Parameters

string $key
mixed $value

Return Value

void

void __construct(Request $request = null)

Create a new Illuminate application instance.

Parameters

Request $request

Return Value

void

protected Request createNewRequest()

Create a new request instance from the request class.

Return Value

Request

protected void registerBaseBindings(Request $request)

Register the basic bindings into the container.

Parameters

Request $request

Return Value

void

protected void registerBaseServiceProviders()

Register all of the base service providers.

Return Value

void

protected void registerExceptionProvider()

Register the exception service provider.

Return Value

void

protected void registerRoutingProvider()

Register the routing service provider.

Return Value

void

protected void registerEventProvider()

Register the event service provider.

Return Value

void

void bindInstallPaths(array $paths)

Bind the installation paths to the application.

Parameters

array $paths

Return Value

void

static string getBootstrapFile()

Get the application bootstrap file.

Return Value

string

void startExceptionHandling()

Start the exception handling for the request.

Return Value

void

string environment()

Get or check the current application environment.

Return Value

string

bool isLocal()

Determine if application is in local environment.

Return Value

bool

string detectEnvironment(array|string $envs)

Detect the application's current environment.

Parameters

array|string $envs

Return Value

string

bool runningInConsole()

Determine if we are running in the console.

Return Value

bool

bool runningUnitTests()

Determine if we are running unit tests.

Return Value

bool

ServiceProvider forceRegister(ServiceProvider|string $provider, array $options = array())

Force register a service provider with the application.

Parameters

ServiceProvider|string $provider
array $options

Return Value

ServiceProvider

ServiceProvider register(ServiceProvider|string $provider, array $options = array(), bool $force = false)

Register a service provider with the application.

Parameters

ServiceProvider|string $provider
array $options
bool $force

Return Value

ServiceProvider

ServiceProvider|null getRegistered(ServiceProvider|string $provider)

Get the registered service provider instance if it exists.

Parameters

ServiceProvider|string $provider

Return Value

ServiceProvider|null

ServiceProvider resolveProviderClass(string $provider)

Resolve a service provider instance from the class name.

Parameters

string $provider

Return Value

ServiceProvider

protected void markAsRegistered(ServiceProvider $provider)

Mark the given provider as registered.

Parameters

ServiceProvider $provider

Return Value

void

void loadDeferredProviders()

Load and boot all of the remaining deferred providers.

Return Value

void

protected void loadDeferredProvider(string $service)

Load the provider for a deferred service.

Parameters

string $service

Return Value

void

void registerDeferredProvider(string $provider, string $service = null)

Register a deferred provider and service.

Parameters

string $provider
string $service

Return Value

void

void before(Closure|string $callback)

Register a "before" application filter.

Parameters

Closure|string $callback

Return Value

void

void after(Closure|string $callback)

Register an "after" application filter.

Parameters

Closure|string $callback

Return Value

void

void finish(Closure|string $callback)

Register a "finish" application filter.

Parameters

Closure|string $callback

Return Value

void

void shutdown(callable $callback = null)

Register a "shutdown" callback.

Parameters

callable $callback

Return Value

void

void useArraySessions(Closure $callback)

Register a function for determining when to use array sessions.

Parameters

Closure $callback

Return Value

void

bool isBooted()

Determine if the application has booted.

Return Value

bool

void boot()

Boot the application's service providers.

Return Value

void

protected void bootApplication()

Boot the application and fire app callbacks.

Return Value

void

void booting(mixed $callback)

Register a new boot listener.

Parameters

mixed $callback

Return Value

void

void booted(mixed $callback)

Register a new "booted" listener.

Parameters

mixed $callback

Return Value

void

void run(Request $request = null)

Run the application and send the response.

Parameters

Request $request

Return Value

void

protected HttpKernelInterface getStackedClient()

Get the stacked HTTP kernel for the application.

Return Value

HttpKernelInterface

protected void mergeCustomMiddlewares(Builder $stack)

Merge the developer defined middlewares onto the stack.

Parameters

Builder $stack

Return Value

void

protected void registerBaseMiddlewares()

Register the default, but optional middlewares.

Return Value

void

$this middleware(string $class, array $parameters = array())

Add a HttpKernel middleware onto the stack.

Parameters

string $class
array $parameters

Return Value

$this

void forgetMiddleware(string $class)

Remove a custom middleware from the application.

Parameters

string $class

Return Value

void

Response handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true)

Handle the given request and get the response.

Provides compatibility with BrowserKit functional testing.

Parameters

Request $request
int $type
bool $catch

Return Value

Response

Exceptions

Exception

Response dispatch(Request $request)

Handle the given request and get the response.

Parameters

Request $request

Return Value

Response

void terminate(Request $request, Response $response)

Call the "finish" and "shutdown" callbacks assigned to the application.

Parameters

Request $request
Response $response

Return Value

void

protected void refreshRequest(Request $request)

Refresh the bound request instance in the container.

Parameters

Request $request

Return Value

void

void callFinishCallbacks(Request $request, Response $response)

Call the "finish" callbacks assigned to the application.

Parameters

Request $request
Response $response

Return Value

void

protected void fireAppCallbacks(array $callbacks)

Call the booting callbacks for the application.

Parameters

array $callbacks

Return Value

void

Request prepareRequest(Request $request)

Prepare the request by injecting any services.

Parameters

Request $request

Return Value

Request

Response prepareResponse(mixed $value)

Prepare the given value as a Response object.

Parameters

mixed $value

Return Value

Response

bool readyForResponses()

Determine if the application is ready for responses.

Return Value

bool

bool isDownForMaintenance()

Determine if the application is currently down for maintenance.

Return Value

bool

void down(Closure $callback)

Register a maintenance mode event listener.

Parameters

Closure $callback

Return Value

void

void abort(int $code, string $message = '', array $headers = array())

Throw an HttpException with the given data.

Parameters

int $code
string $message
array $headers

Return Value

void

Exceptions

HttpException
NotFoundHttpException

void missing(Closure $callback)

Register a 404 error handler.

Parameters

Closure $callback

Return Value

void

void error(Closure $callback)

Register an application error handler.

Parameters

Closure $callback

Return Value

void

void pushError(Closure $callback)

Register an error handler at the bottom of the stack.

Parameters

Closure $callback

Return Value

void

void fatal(Closure $callback)

Register an error handler for fatal errors.

Parameters

Closure $callback

Return Value

void

LoaderInterface getConfigLoader()

Get the configuration loader instance.

Return Value

LoaderInterface

EnvironmentVariablesLoaderInterface getEnvironmentVariablesLoader()

Get the environment variables loader instance.

ProviderRepository getProviderRepository()

Get the service provider repository instance.

Return Value

ProviderRepository

array getLoadedProviders()

Get the service providers that have been loaded.

Return Value

array

void setDeferredServices(array $services)

Set the application's deferred services.

Parameters

array $services

Return Value

void

bool isDeferredService(string $service)

Determine if the given service is a deferred service.

Parameters

string $service

Return Value

bool

static string requestClass(string $class = null)

Get or set the request class for the application.

Parameters

string $class

Return Value

string

void setRequestForConsoleEnvironment()

Set the application request for the console environment.

Return Value

void

static mixed onRequest(string $method, array $parameters = array())

Call a method on the default request class.

Parameters

string $method
array $parameters

Return Value

mixed

string getLocale()

Get the current application locale.

Return Value

string

void setLocale(string $locale)

Set the current application locale.

Parameters

string $locale

Return Value

void

void registerCoreContainerAliases()

Register the core class aliases in the container.

Return Value

void