Container
interface Container implements ContainerInterface (View source)
Methods
{@inheritdoc}
Determine if the given abstract type has been bound.
Alias a type to a different name.
Assign a set of tags to a given binding.
Resolve all of the bindings for a given tag.
Bind a callback to resolve with Container::call.
Register a shared binding if it hasn't already been registered.
Register an existing instance as shared in the container.
Add a contextual binding to the container.
Define a contextual binding.
Get a closure to resolve the given type from the container.
Flush the container of all bindings and resolved instances.
Resolve the given type from the container.
Call the given Closure / class@method and inject its dependencies.
Determine if the given abstract type has been resolved.
Register a new before resolving callback.
Register a new after resolving callback.
Details
TClass : mixed)
get(string $id)
{@inheritdoc}
bool
bound(string $abstract)
Determine if the given abstract type has been bound.
void
alias(string $abstract, string $alias)
Alias a type to a different name.
void
tag(array|string $abstracts, array|mixed $tags)
Assign a set of tags to a given binding.
iterable
tagged(string $tag)
Resolve all of the bindings for a given tag.
void
bind(string $abstract, Closure|string|null $concrete = null, bool $shared = false)
Register a binding with the container.
void
bindMethod(array|string $method, Closure $callback)
Bind a callback to resolve with Container::call.
void
bindIf(string $abstract, Closure|string|null $concrete = null, bool $shared = false)
Register a binding if it hasn't already been registered.
void
singleton(string $abstract, Closure|string|null $concrete = null)
Register a shared binding in the container.
void
singletonIf(string $abstract, Closure|string|null $concrete = null)
Register a shared binding if it hasn't already been registered.
void
scoped(string $abstract, Closure|string|null $concrete = null)
Register a scoped binding in the container.
void
scopedIf(string $abstract, Closure|string|null $concrete = null)
Register a scoped binding if it hasn't already been registered.
void
extend(string $abstract, Closure $closure)
"Extend" an abstract type in the container.
TInstance
instance(string $abstract, TInstance $instance)
Register an existing instance as shared in the container.
void
addContextualBinding(string $concrete, string $abstract, Closure|string $implementation)
Add a contextual binding to the container.
ContextualBindingBuilder
when(string|array $concrete)
Define a contextual binding.
Closure(): mixed)
factory(string|TClass> $abstract)
Get a closure to resolve the given type from the container.
void
flush()
Flush the container of all bindings and resolved instances.
TClass : mixed)
make(string|TClass> $abstract, array $parameters = [])
Resolve the given type from the container.
mixed
call(callable|string $callback, array $parameters = [], string|null $defaultMethod = null)
Call the given Closure / class@method and inject its dependencies.
bool
resolved(string $abstract)
Determine if the given abstract type has been resolved.
void
beforeResolving(Closure|string $abstract, Closure|null $callback = null)
Register a new before resolving callback.
void
resolving(Closure|string $abstract, Closure|null $callback = null)
Register a new resolving callback.
Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.