Application
class Application extends Container implements Application, HttpKernelInterface
Constants
VERSION |
The Laravel framework version. |
Properties
static protected Container | $instance | The current globally available container (if any). |
from Container |
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 | $methodBindings | The container's method bindings. |
from Container |
protected array | $instances | The container's shared instances. |
from Container |
protected array | $aliases | The registered type aliases. |
from Container |
protected array | $abstractAliases | The registered aliases keyed by the abstract name. |
from Container |
protected array | $extenders | The extension closures for services. |
from Container |
protected array | $tags | All of the registered tags. |
from Container |
protected array | $buildStack | The stack of concretions currently being built. |
from Container |
protected array | $with | The parameter override stack. |
from Container |
array | $contextual | The contextual binding map. |
from Container |
protected array | $reboundCallbacks | All of the registered rebound callbacks. |
from Container |
protected array | $globalResolvingCallbacks | All of the global resolving callbacks. |
from Container |
protected array | $globalAfterResolvingCallbacks | All of the global after resolving callbacks. |
from Container |
protected array | $resolvingCallbacks | All of the resolving callbacks by class type. |
from Container |
protected array | $afterResolvingCallbacks | All of the after resolving callbacks by class type. |
from Container |
protected string | $basePath | The base path for the Laravel installation. |
|
protected bool | $hasBeenBootstrapped | Indicates if the application has been bootstrapped before. |
|
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 | $terminatingCallbacks | The array of terminating callbacks. |
|
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. |
|
protected callable|null | $monologConfigurator | A custom callback used to configure Monolog. |
|
protected string | $databasePath | The custom database path defined by the developer. |
|
protected string | $storagePath | The custom storage path defined by the developer. |
|
protected string | $environmentPath | The custom environment path defined by the developer. |
|
protected string | $environmentFile | The environment file to load during bootstrapping. |
|
protected string | $namespace | The application namespace. |
Methods
Determine if the given abstract type has been bound.
Determine if the given abstract type has been resolved.
Register a binding with the container.
Get the Closure to be used when building a type.
Determine if the container has a method binding.
Get the method binding for the given method.
Add a contextual binding to the container.
Register a binding if it hasn't already been registered.
Register a shared binding in the container.
Register an existing instance as shared in the container.
Remove an alias from the contextual binding alias cache.
Assign a set of tags to a given binding.
Refresh an instance on the given target and method.
Fire the "rebound" callbacks for the given abstract type.
Get the rebound callbacks for a given type.
Wrap the given closure such that its dependencies will be injected when executed.
Call the given Closure / class@method and inject its dependencies.
Get a closure to resolve the given type from the container.
Resolve the given type from the container.
Resolve the given type from the container.
Resolve the given type from the container.
Get the contextual concrete binding for the given abstract.
Find the concrete binding for the given abstract in the contextual binding array.
Determine if the given concrete is buildable.
Resolve all of the dependencies from the ReflectionParameters.
Determine if the given dependency has a parameter override from makeWith.
Throw an exception that the concrete is not instantiable.
Throw an exception for an unresolvable primitive.
Register a new after resolving callback for all types.
Fire all of the resolving callbacks.
Fire all of the after resolving callbacks.
Get all callbacks for a given type.
Fire an array of callbacks with an object.
Remove all of the extender callbacks for a given type.
Drop all of the stale instances and aliases.
Remove a resolved instance from the instance cache.
Flush the container of all bindings and resolved instances.
Create a new Illuminate application instance.
Get the version number of the application.
Register the basic bindings into the container.
Register all of the base service providers.
Run the given array of bootstrap classes.
Register a callback to run after loading the environment.
Register a callback to run before a bootstrapper.
Register a callback to run after a bootstrapper.
Determine if the application has been bootstrapped before.
Set the base path for the application.
Bind all of the application paths in the container.
Get the path to the application "app" directory.
Get the base path of the Laravel installation.
Get the path to the bootstrap directory.
Get the path to the application configuration files.
Get the path to the database directory.
Set the database directory.
Get the path to the language files.
Get the path to the public / web directory.
Get the path to the storage directory.
Set the storage directory.
Get the path to the resources directory.
Get the path to the environment file directory.
Set the directory for the environment file.
Set the environment file to be loaded during bootstrapping.
Get the environment file the application is using.
Get the fully qualified path to the environment file.
Get or check the current application environment.
Determine if application is in local environment.
Determine if we are running in the console.
Determine if we are running unit tests.
Register all of the configured providers.
Register a service provider with the application.
Get the registered service provider instance if it exists.
Resolve a service provider instance from the class name.
Load and boot all of the remaining deferred providers.
Load the provider for a deferred service.
Register a deferred provider and service.
Determine if the application has booted.
Boot the application's service providers.
Register a new boot listener.
Register a new "booted" listener.
Call the booting callbacks for the application.
{@inheritdoc}
Determine if middleware has been disabled for the application.
Get the path to the cached services.php file.
Determine if the application configuration is cached.
Get the path to the configuration cache file.
Determine if the application routes are cached.
Get the path to the routes cache file.
Determine if the application is currently down for maintenance.
Throw an HttpException with the given data.
Terminate the application.
Get the service providers that have been loaded.
Get the application's deferred services.
Set the application's deferred services.
Add an array of services to the application's deferred services.
Determine if the given service is a deferred service.
Configure the real-time facade namespace.
Define a callback to be used to configure Monolog.
Determine if the application has a custom Monolog configurator.
Get the custom Monolog configurator for the application.
Get the current application locale.
Set the current application locale.
Determine if application locale is the given locale.
Register the core class aliases in the container.
Get the application namespace.
Details
in
Container at line 140
ContextualBindingBuilder
when(string $concrete)
Define a contextual binding.
at line 739
bool
bound(string $abstract)
Determine if the given abstract type has been bound.
(Overriding Container::bound)
in
Container at line 164
bool
resolved(string $abstract)
Determine if the given abstract type has been resolved.
in
Container at line 180
bool
isShared(string $abstract)
Determine if a given type is shared.
in
Container at line 193
bool
isAlias(string $name)
Determine if a given string is an alias.
in
Container at line 206
void
bind(string|array $abstract, Closure|string|null $concrete = null, bool $shared = false)
Register a binding with the container.
in
Container at line 241
protected Closure
getClosure(string $abstract, string $concrete)
Get the Closure to be used when building a type.
in
Container at line 258
bool
hasMethodBinding(string $method)
Determine if the container has a method binding.
in
Container at line 270
void
bindMethod(string $method, Closure $callback)
Bind a callback to resolve with Container::call.
in
Container at line 282
mixed
callMethodBinding(string $method, mixed $instance)
Get the method binding for the given method.
in
Container at line 295
void
addContextualBinding(string $concrete, string $abstract, Closure|string $implementation)
Add a contextual binding to the container.
in
Container at line 308
void
bindIf(string $abstract, Closure|string|null $concrete = null, bool $shared = false)
Register a binding if it hasn't already been registered.
in
Container at line 322
void
singleton(string|array $abstract, Closure|string|null $concrete = null)
Register a shared binding in the container.
in
Container at line 336
void
extend(string $abstract, Closure $closure)
"Extend" an abstract type in the container.
in
Container at line 360
void
instance(string $abstract, mixed $instance)
Register an existing instance as shared in the container.
in
Container at line 384
protected void
removeAbstractAlias(string $searched)
Remove an alias from the contextual binding alias cache.
in
Container at line 406
void
tag(array|string $abstracts, array|mixed $tags)
Assign a set of tags to a given binding.
in
Container at line 427
array
tagged(array $tag)
Resolve all of the bindings for a given tag.
in
Container at line 447
void
alias(string $abstract, string $alias)
Alias a type to a different name.
in
Container at line 461
mixed
rebinding(string $abstract, Closure $callback)
Bind a new callback to an abstract's rebind event.
in
Container at line 478
mixed
refresh(string $abstract, mixed $target, string $method)
Refresh an instance on the given target and method.
in
Container at line 491
protected void
rebound(string $abstract)
Fire the "rebound" callbacks for the given abstract type.
in
Container at line 506
protected array
getReboundCallbacks(string $abstract)
Get the rebound callbacks for a given type.
in
Container at line 522
Closure
wrap(Closure $callback, array $parameters = [])
Wrap the given closure such that its dependencies will be injected when executed.
in
Container at line 537
mixed
call(callable|string $callback, array $parameters = [], string|null $defaultMethod = null)
Call the given Closure / class@method and inject its dependencies.
in
Container at line 548
Closure
factory(string $abstract)
Get a closure to resolve the given type from the container.
at line 701
mixed
makeWith(string $abstract, array $parameters)
Resolve the given type from the container.
(Overriding Container::makeWith)
at line 720
mixed
make(string $abstract)
Resolve the given type from the container.
(Overriding Container::make)
in
Container at line 585
protected mixed
resolve(string $abstract, array $parameters = [])
Resolve the given type from the container.
in
Container at line 645
protected mixed
getConcrete(string $abstract)
Get the concrete type for a given abstract.
in
Container at line 667
protected string|null
getContextualConcrete(string $abstract)
Get the contextual concrete binding for the given abstract.
in
Container at line 693
protected string|null
findInContextualBindings(string $abstract)
Find the concrete binding for the given abstract in the contextual binding array.
in
Container at line 707
protected bool
isBuildable(mixed $concrete, string $abstract)
Determine if the given concrete is buildable.
in
Container at line 720
mixed
build(string $concrete)
Instantiate a concrete instance of the given type.
in
Container at line 771
protected array
resolveDependencies(array $dependencies)
Resolve all of the dependencies from the ReflectionParameters.
in
Container at line 802
protected bool
hasParameterOverride(ReflectionParameter $dependency)
Determine if the given dependency has a parameter override from makeWith.
in
Container at line 815
protected mixed
getParameterOverride(ReflectionParameter $dependency)
Get a parameter override for a dependency.
in
Container at line 825
protected array
getLastParameterOverride()
Get the last parameter override.
in
Container at line 838
protected mixed
resolvePrimitive(ReflectionParameter $parameter)
Resolve a non-class hinted primitive dependency.
in
Container at line 859
protected mixed
resolveClass(ReflectionParameter $parameter)
Resolve a class based dependency from the container.
in
Container at line 885
protected void
notInstantiable(string $concrete)
Throw an exception that the concrete is not instantiable.
in
Container at line 906
protected void
unresolvablePrimitive(ReflectionParameter $parameter)
Throw an exception for an unresolvable primitive.
in
Container at line 920
void
resolving(string $abstract, Closure $callback = null)
Register a new resolving callback.
in
Container at line 940
void
afterResolving(string $abstract, Closure $callback = null)
Register a new after resolving callback for all types.
in
Container at line 960
protected void
fireResolvingCallbacks(string $abstract, mixed $object)
Fire all of the resolving callbacks.
in
Container at line 978
protected void
fireAfterResolvingCallbacks(string $abstract, mixed $object)
Fire all of the after resolving callbacks.
in
Container at line 996
protected array
getCallbacksForType(string $abstract, object $object, array $callbacksPerType)
Get all callbacks for a given type.
in
Container at line 1016
protected void
fireCallbackArray(mixed $object, array $callbacks)
Fire an array of callbacks with an object.
in
Container at line 1028
array
getBindings()
Get the container's bindings.
in
Container at line 1041
string
getAlias(string $abstract)
Get the alias for an abstract if available.
in
Container at line 1060
protected array
getExtenders(string $abstract)
Get the extender callbacks for a given type.
in
Container at line 1077
void
forgetExtenders(string $abstract)
Remove all of the extender callbacks for a given type.
in
Container at line 1088
protected void
dropStaleInstances(string $abstract)
Drop all of the stale instances and aliases.
in
Container at line 1099
void
forgetInstance(string $abstract)
Remove a resolved instance from the instance cache.
in
Container at line 1109
void
forgetInstances()
Clear all of the instances from the container.
at line 1141
void
flush()
Flush the container of all bindings and resolved instances.
in
Container at line 1133
static Container
getInstance()
Set the globally available instance of the container.
in
Container at line 1148
static Container
setInstance(Container $container = null)
Set the shared instance of the container.
in
Container at line 1159
bool
offsetExists(string $key)
Determine if a given offset exists.
in
Container at line 1170
mixed
offsetGet(string $key)
Get the value at a given offset.
in
Container at line 1182
void
offsetSet(string $key, mixed $value)
Set the value at a given offset.
in
Container at line 1195
void
offsetUnset(string $key)
Unset the value at a given offset.
in
Container at line 1206
mixed
__get(string $key)
Dynamically access container services.
in
Container at line 1218
void
__set(string $key, mixed $value)
Dynamically set container services.
at line 144
void
__construct(string|null $basePath = null)
Create a new Illuminate application instance.
at line 162
string
version()
Get the version number of the application.
at line 172
protected void
registerBaseBindings()
Register the basic bindings into the container.
at line 186
protected void
registerBaseServiceProviders()
Register all of the base service providers.
at line 201
void
bootstrapWith(array $bootstrappers)
Run the given array of bootstrap classes.
at line 220
void
afterLoadingEnvironment(Closure $callback)
Register a callback to run after loading the environment.
at line 234
void
beforeBootstrapping(string $bootstrapper, Closure $callback)
Register a callback to run before a bootstrapper.
at line 246
void
afterBootstrapping(string $bootstrapper, Closure $callback)
Register a callback to run after a bootstrapper.
at line 256
bool
hasBeenBootstrapped()
Determine if the application has been bootstrapped before.
at line 267
$this
setBasePath(string $basePath)
Set the base path for the application.
at line 281
protected void
bindPathsInContainer()
Bind all of the application paths in the container.
at line 300
string
path(string $path = '')
Get the path to the application "app" directory.
at line 311
string
basePath(string $path = '')
Get the base path of the Laravel installation.
at line 322
string
bootstrapPath(string $path = '')
Get the path to the bootstrap directory.
at line 333
string
configPath(string $path = '')
Get the path to the application configuration files.
at line 344
string
databasePath(string $path = '')
Get the path to the database directory.
at line 355
$this
useDatabasePath(string $path)
Set the database directory.
at line 369
string
langPath()
Get the path to the language files.
at line 379
string
publicPath()
Get the path to the public / web directory.
at line 389
string
storagePath()
Get the path to the storage directory.
at line 400
$this
useStoragePath(string $path)
Set the storage directory.
at line 415
string
resourcePath(string $path = '')
Get the path to the resources directory.
at line 425
string
environmentPath()
Get the path to the environment file directory.
at line 436
$this
useEnvironmentPath(string $path)
Set the directory for the environment file.
at line 449
$this
loadEnvironmentFrom(string $file)
Set the environment file to be loaded during bootstrapping.
at line 461
string
environmentFile()
Get the environment file the application is using.
at line 471
string
environmentFilePath()
Get the fully qualified path to the environment file.
at line 481
string
environment()
Get or check the current application environment.
at line 503
bool
isLocal()
Determine if application is in local environment.
at line 514
string
detectEnvironment(Closure $callback)
Detect the application's current environment.
at line 526
bool
runningInConsole()
Determine if we are running in the console.
at line 536
bool
runningUnitTests()
Determine if we are running unit tests.
at line 546
void
registerConfiguredProviders()
Register all of the configured providers.
at line 560
ServiceProvider
register(ServiceProvider|string $provider, array $options = [], bool $force = false)
Register a service provider with the application.
at line 595
ServiceProvider|null
getProvider(ServiceProvider|string $provider)
Get the registered service provider instance if it exists.
at line 610
ServiceProvider
resolveProvider(string $provider)
Resolve a service provider instance from the class name.
at line 621
protected void
markAsRegistered(ServiceProvider $provider)
Mark the given provider as registered.
at line 633
void
loadDeferredProviders()
Load and boot all of the remaining deferred providers.
at line 651
void
loadDeferredProvider(string $service)
Load the provider for a deferred service.
at line 674
void
registerDeferredProvider(string $provider, string|null $service = null)
Register a deferred provider and service.
at line 749
bool
isBooted()
Determine if the application has booted.
at line 759
void
boot()
Boot the application's service providers.
at line 785
protected mixed
bootProvider(ServiceProvider $provider)
Boot the given service provider.
at line 798
void
booting(mixed $callback)
Register a new boot listener.
at line 809
void
booted(mixed $callback)
Register a new "booted" listener.
at line 824
protected void
fireAppCallbacks(array $callbacks)
Call the booting callbacks for the application.
at line 834
handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
{@inheritdoc}
at line 844
bool
shouldSkipMiddleware()
Determine if middleware has been disabled for the application.
at line 855
string
getCachedServicesPath()
Get the path to the cached services.php file.
at line 865
bool
configurationIsCached()
Determine if the application configuration is cached.
at line 875
string
getCachedConfigPath()
Get the path to the configuration cache file.
at line 885
bool
routesAreCached()
Determine if the application routes are cached.
at line 895
string
getCachedRoutesPath()
Get the path to the routes cache file.
at line 905
bool
isDownForMaintenance()
Determine if the application is currently down for maintenance.
at line 920
void
abort(int $code, string $message = '', array $headers = [])
Throw an HttpException with the given data.
at line 935
$this
terminating(Closure $callback)
Register a terminating callback with the application.
at line 947
void
terminate()
Terminate the application.
at line 959
array
getLoadedProviders()
Get the service providers that have been loaded.
at line 969
array
getDeferredServices()
Get the application's deferred services.
at line 980
void
setDeferredServices(array $services)
Set the application's deferred services.
at line 991
void
addDeferredServices(array $services)
Add an array of services to the application's deferred services.
at line 1002
bool
isDeferredService(string $service)
Determine if the given service is a deferred service.
at line 1013
void
provideFacades(string $namespace)
Configure the real-time facade namespace.
at line 1024
$this
configureMonologUsing(callable $callback)
Define a callback to be used to configure Monolog.
at line 1036
bool
hasMonologConfigurator()
Determine if the application has a custom Monolog configurator.
at line 1046
callable
getMonologConfigurator()
Get the custom Monolog configurator for the application.
at line 1056
string
getLocale()
Get the current application locale.
at line 1067
void
setLocale(string $locale)
Set the current application locale.
at line 1082
bool
isLocale(string $locale)
Determine if application locale is the given locale.
at line 1092
void
registerCoreContainerAliases()
Register the core class aliases in the container.
at line 1155
string
getNamespace()
Get the application namespace.