Container
class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, Countable
Class Container
Traits
Constants
DEFAULT_OPTIONS |
|
Properties
protected array | $aliases | 服务别名 | |
string | $name | 当前容器名称,初始时即固定 | |
protected Container | $parent | 当前容器的父级容器 |
Methods
set/get name alias
No description
No description
在容器注册服务(详细的参数信息请查看README.md)
通过设置配置的多维数组 注册多个服务. 服务详细设置请看{see self::set()}
注册受保护的服务 alias of the lock()
(注册)锁定的服务,也可在注册后锁定,防止 getNew() 强制重载
No description
创建(类实例/类的方法)回调
get 获取已注册的服务组件实例 - (单例)共享服务总是获取已存储的实例 - 其他的则总是返回新的实例
强制获取服务的新实例,针对共享服务
No description
若存在服务则返回 否则返回 null
No description
删除服务
get 获取已注册的服务组件实例
获取某一个服务的信息
clear
获取全部服务信息
获取全部服务id
No description
No description
No description
No description
No description
No description
Defined by IteratorAggregate interface Returns an iterator for this object, for use with foreach
Checks whether an offset exists in the iterator.
Gets an offset in the iterator.
Sets an offset in the iterator.
Unset an offset in the iterator.
Details
in NameAliasTrait at line 26
bool|string
alias(array|string $name, array|string|null $alias = null)
set/get name alias
at line 485
mixed
resolveAlias(string $alias)
in NameAliasTrait at line 72
bool
hasAlias(string $alias)
in NameAliasTrait at line 80
array
getAliases()
in NameAliasTrait at line 89
$this
setAliases(array $aliases)
at line 79
__construct(array $services = [], Container $parent = null)
Container constructor.
at line 86
__destruct()
at line 103
$this
set(string $id, $definition, array $opts = [])
在容器注册服务(详细的参数信息请查看README.md)
at line 183
$this
sets(array $services)
通过设置配置的多维数组 注册多个服务. 服务详细设置请看{see self::set()}
at line 215
$this
protect(string $id, $definition, $share = false)
注册受保护的服务 alias of the lock()
at line 229
$this
lock(string $id, $definition, $share = false)
(注册)锁定的服务,也可在注册后锁定,防止 getNew() 强制重载
at line 242
$this
registerServiceProvider(ServiceProviderInterface $provider)
注册服务提供者(可能含有多个服务)
at line 253
$this
registerServiceProviders(array $providers)
at line 272
callable
createCallback(mixed $target, array $arguments = [], array $props = [])
创建(类实例/类的方法)回调
at line 353
mixed
get(string $id)
get 获取已注册的服务组件实例 - (单例)共享服务总是获取已存储的实例 - 其他的则总是返回新的实例
at line 374
mixed
getNew(string $id)
强制获取服务的新实例,针对共享服务
at line 383
mixed|null
new(string $id)
at line 394
mixed|null
getIfExist(string $id)
若存在服务则返回 否则返回 null
at line 405
mixed
raw(string $id)
at line 420
del(string $id)
删除服务
at line 441
mixed|null
getInstance(string $id, bool $thrErr = true, bool $forceNew = false)
get 获取已注册的服务组件实例
at line 466
Service|null
getService(string $id, bool $thrErr = false)
获取某一个服务的信息
at line 498
clear()
clear
at line 512
array
getServices()
获取全部服务信息
at line 534
array
getIds(bool $toArray = true)
获取全部服务id
at line 546
bool
isShared(string $id)
at line 560
bool
isLocked(string $id)
at line 576
bool|Service
has(string $id)
是已注册的服务
at line 585
bool
exists(string $id)
at line 614
bool|Service
__isset($name)
at line 625
__set($name, $value)
at line 636
bool
__get($name)
at line 658
int
count()
at line 668
ArrayIterator
getIterator()
Defined by IteratorAggregate interface Returns an iterator for this object, for use with foreach
at line 678
boolean
offsetExists(mixed $offset)
Checks whether an offset exists in the iterator.
at line 689
mixed
offsetGet(mixed $offset)
Gets an offset in the iterator.
at line 702
$this
offsetSet(mixed $offset, mixed $value)
Sets an offset in the iterator.
at line 712
void
offsetUnset(mixed $offset)
Unset an offset in the iterator.