Container
class Container
The dependency injection container default implementation.
Properties
| array deprecated | $parameters | ||
| protected string[] | $aliases | ||
| protected array<string,array<string,mixed>> | $tags | ||
| protected array<class-string,array<int,list<string>>> | $wiring |
Methods
No description
No description
Returns a parameter value, loading it dynamically if not yet initialized.
No description
No description
Adds the service or its factory to the container.
Removes a service instance from the container.
Returns the service instance. If it has not been created yet, it creates it.
Returns the service instance. If it has not been created yet, it creates it.
Returns type of the service.
Checks whether the service exists in the container.
Has a service instance been created?
Creates new instance of the service.
Returns an instance of the autowired service of the given type. If it has not been created yet, it creates it.
Returns the names of autowired services of the given type.
Returns the names of all services of the given type.
Returns the names of services with the given tag.
Returns all registered services as a map of service name to type.
Returns the alias map: alias name => canonical service name.
Returns services that have already been instantiated, indexed by service name.
Returns the tags attached to the given service.
Creates an instance of the class and passes dependencies to the constructor using autowiring.
Calls all methods starting with 'inject' and passes dependencies to them via autowiring.
Calls the method and passes dependencies to it via autowiring.
Returns the method name for creating a service.
No description
Details
at line 48
__construct(array $params = [])
No description
at line 56
array
getParameters()
No description
at line 65
mixed
getParameter(string|int $key)
Returns a parameter value, loading it dynamically if not yet initialized.
at line 75
protected array
getStaticParameters()
No description
at line 81
protected mixed
getDynamicParameter(string|int $key)
No description
at line 91
Container
addService(string $name, object $service)
Adds the service or its factory to the container.
at line 130
void
removeService(string $name)
Removes a service instance from the container.
at line 141
object
getService(string $name)
Returns the service instance. If it has not been created yet, it creates it.
at line 160
object
getByName(string $name)
Returns the service instance. If it has not been created yet, it creates it.
Alias for getService().
at line 171
string
getServiceType(string $name)
Returns type of the service.
at line 192
bool
hasService(string $name)
Checks whether the service exists in the container.
at line 202
bool
isCreated(string $name)
Has a service instance been created?
at line 217
object
createService(string $name)
Creates new instance of the service.
at line 247
object|null
getByType(string $type, bool $throw = true)
Returns an instance of the autowired service of the given type. If it has not been created yet, it creates it.
at line 277
array
findAutowired(string $type)
Returns the names of autowired services of the given type.
at line 289
array
findByType(string $type)
Returns the names of all services of the given type.
at line 302
array
findByTag(string $tag)
Returns the names of services with the given tag.
at line 313
array
getServiceTypes()
Returns all registered services as a map of service name to type.
Aliases are not included — use getAliases() separately.
at line 333
array
getAliases()
Returns the alias map: alias name => canonical service name.
at line 343
array
getInstantiatedServices()
Returns services that have already been instantiated, indexed by service name.
at line 353
array
getServiceTags(string $name)
Returns the tags attached to the given service.
at line 394
object
createInstance(string $class, array $args = [])
Creates an instance of the class and passes dependencies to the constructor using autowiring.
at line 414
void
callInjects(object $service)
Calls all methods starting with 'inject' and passes dependencies to them via autowiring.
at line 424
mixed
callMethod(callable $function, array $args = [])
Calls the method and passes dependencies to it via autowiring.
at line 445
final static string
getMethodName(string $name)
Returns the method name for creating a service.
at line 455
void
initialize()
No description