class Container implements ArrayAccess, Container (View source)

Properties

array $contextual The contextual binding map.

Methods

when( string $concrete)

Define a contextual binding.

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.

bool
isAlias( string $name)

Determine if a given string is an alias.

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

Register a binding with the container.

void
addContextualBinding( string $concrete, string $abstract, Closure|string $implementation)

Add a contextual binding to the container.

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|array $abstract, Closure|string|null $concrete = null)

Register a shared binding in the container.

share( Closure $closure)

Wrap a Closure such that it is shared.

void
extend( string $abstract, Closure $closure)

"Extend" an abstract type in the container.

void
instance( string $abstract, mixed $instance)

Register an existing instance as shared in the container.

void
tag( array|string $abstracts, array|mixed $tags)

Assign a set of tags to a given binding.

array
tagged( array $tag)

Resolve all of the bindings for a given tag.

void
alias( string $abstract, string $alias)

Alias a type to a different name.

mixed
rebinding( string $abstract, Closure $callback)

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

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

Refresh an instance on the given target and method.

wrap( Closure $callback, array $parameters = array())

Wrap the given closure such that its dependencies will be injected when executed.

mixed
call( callable|string $callback, array $parameters = array(), string|null $defaultMethod = null)

Call the given Closure / class@method and inject its dependencies.

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

Resolve the given type from the container.

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

Instantiate a concrete instance of the given type.

void
resolving( string $abstract, Closure $callback = null)

Register a new resolving callback.

void
afterResolving( string $abstract, Closure $callback = null)

Register a new after resolving callback for all types.

bool
isShared( string $abstract)

Determine if a given type is shared.

array
getBindings()

Get the container's bindings.

void
forgetInstance( string $abstract)

Remove a resolved instance from the instance cache.

void
forgetInstances()

Clear all of the instances from the container.

void
flush()

Flush the container of all bindings and resolved instances.

static  Container
getInstance()

Set the globally available instance of the container.

static  void
setInstance( Container $container)

Set the shared instance of the container.

bool
offsetExists( string $key)

Determine if a given offset exists.

mixed
offsetGet( string $key)

Get the value at a given offset.

void
offsetSet( string $key, mixed $value)

Set the value at a given offset.

void
offsetUnset( string $key)

Unset the value at a given offset.

mixed
__get( string $key)

Dynamically access container services.

void
__set( string $key, mixed $value)

Dynamically set container services.

Details

at line line 121
ContextualBindingBuilder when( string $concrete)

Define a contextual binding.

Parameters

string $concrete

Return Value

ContextualBindingBuilder

at line line 134
bool bound( string $abstract)

Determine if the given abstract type has been bound.

Parameters

string $abstract

Return Value

bool

at line line 147
bool resolved( string $abstract)

Determine if the given abstract type has been resolved.

Parameters

string $abstract

Return Value

bool

at line line 164
bool isAlias( string $name)

Determine if a given string is an alias.

Parameters

string $name

Return Value

bool

at line line 177
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

at line line 242
void addContextualBinding( string $concrete, string $abstract, Closure|string $implementation)

Add a contextual binding to the container.

Parameters

string $concrete
string $abstract
Closure|string $implementation

Return Value

void

at line line 255
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

at line line 269
void singleton( string|array $abstract, Closure|string|null $concrete = null)

Register a shared binding in the container.

Parameters

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

Return Value

void

at line line 280
Closure share( Closure $closure)

Wrap a Closure such that it is shared.

Parameters

Closure $closure

Return Value

Closure

at line line 305
void extend( string $abstract, Closure $closure)

"Extend" an abstract type in the container.

Parameters

string $abstract
Closure $closure

Return Value

void

Exceptions

InvalidArgumentException

at line line 325
void instance( string $abstract, mixed $instance)

Register an existing instance as shared in the container.

Parameters

string $abstract
mixed $instance

Return Value

void

at line line 359
void tag( array|string $abstracts, array|mixed $tags)

Assign a set of tags to a given binding.

Parameters

array|string $abstracts
array|mixed $tags

Return Value

void

at line line 380
array tagged( array $tag)

Resolve all of the bindings for a given tag.

Parameters

array $tag

Return Value

array

at line line 400
void alias( string $abstract, string $alias)

Alias a type to a different name.

Parameters

string $abstract
string $alias

Return Value

void

at line line 423
mixed rebinding( string $abstract, Closure $callback)

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

Parameters

string $abstract
Closure $callback

Return Value

mixed

at line line 440
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

at line line 484
Closure wrap( Closure $callback, array $parameters = array())

Wrap the given closure such that its dependencies will be injected when executed.

Parameters

Closure $callback
array $parameters

Return Value

Closure

at line line 499
mixed call( callable|string $callback, array $parameters = array(), string|null $defaultMethod = null)

Call the given Closure / class@method and inject its dependencies.

Parameters

callable|string $callback
array $parameters
string|null $defaultMethod

Return Value

mixed

at line line 616
mixed make( string $abstract, array $parameters = array())

Resolve the given type from the container.

Parameters

string $abstract
array $parameters

Return Value

mixed

at line line 729
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

at line line 895
void resolving( string $abstract, Closure $callback = null)

Register a new resolving callback.

Parameters

string $abstract
Closure $callback

Return Value

void

at line line 911
void afterResolving( string $abstract, Closure $callback = null)

Register a new after resolving callback for all types.

Parameters

string $abstract
Closure $callback

Return Value

void

at line line 1045
bool isShared( string $abstract)

Determine if a given type is shared.

Parameters

string $abstract

Return Value

bool

at line line 1088
array getBindings()

Get the container's bindings.

Return Value

array

at line line 1110
void forgetInstance( string $abstract)

Remove a resolved instance from the instance cache.

Parameters

string $abstract

Return Value

void

at line line 1120
void forgetInstances()

Clear all of the instances from the container.

Return Value

void

at line line 1130
void flush()

Flush the container of all bindings and resolved instances.

Return Value

void

at line line 1143
static Container getInstance()

Set the globally available instance of the container.

Return Value

Container

at line line 1154
static void setInstance( Container $container)

Set the shared instance of the container.

Parameters

Container $container

Return Value

void

at line line 1165
bool offsetExists( string $key)

Determine if a given offset exists.

Parameters

string $key

Return Value

bool

at line line 1176
mixed offsetGet( string $key)

Get the value at a given offset.

Parameters

string $key

Return Value

mixed

at line line 1188
void offsetSet( string $key, mixed $value)

Set the value at a given offset.

Parameters

string $key
mixed $value

Return Value

void

at line line 1208
void offsetUnset( string $key)

Unset the value at a given offset.

Parameters

string $key

Return Value

void

at line line 1221
mixed __get( string $key)

Dynamically access container services.

Parameters

string $key

Return Value

mixed

at line line 1233
void __set( string $key, mixed $value)

Dynamically set container services.

Parameters

string $key
mixed $value

Return Value

void