zloynick/joole-containers
Composer 安装命令:
composer require zloynick/joole-containers
包简介
README 文档
README
Joole Containers is a library for storing objects. At its core, it is an implementation of PSR-12 and its complement.
Getting started
- Install it with using composer:
composer require zloynick/joole-containers
Using
- Create a container object:
use joole\containers\Container;
$container = new Container();
...
- Register your object to created container:
...
class MyCustomPeople{
private string $age;
private string $name;
public function __construct(
$name,
$age
)
{
$this->name = $name;
$this->age = $age;
}
public function getName(): string
{
return $this->name;
}
}
$container->register(MyCustomPeople::class, ['name' => 'Alex', 'age' => 22]);
...
Now we can use the object from the container
...
echo $container->get(MyCustomPeople::class)->getName();// Alex
...
Addition functional
- You can get number of object in container:
$count = count($container); - Multiple push:
$container->multiplePush(['param1' => [1, 2, 3], 'param2' => new stdClass()], Class1::class, Class2::class);
Note: the keys of the array of parameters must correspond to the name of the variables of the constructor classthe keys of the array of parameters must correspond to the name of the variables of the constructor class.
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2022-04-26