2017 © Pedro Peláez
 

library container

a container for interface and container

image

graychen/container

a container for interface and container

  • Thursday, February 22, 2018
  • by Graychen
  • Repository
  • 1 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

一个容器为了接口和实体类的解耦

StyleCI Build Status Scrutinizer Code Quality Code Coverage Code Coverage, (*1)

如何导入

composer require graychen/container

如何使用

首先我们在文件中引入我们的容器, (*2)

 use graychen\container\Container;

然后我们再将类注册到容器中,用字符串进行映射, (*3)

匿名函数方式注册

$container = new Container();
$container->setShared("logShared", function ($content="") {
    return new Log($content);
});
$log=$container->get("logShared", array("writeContent"));

类名方式注册

$container = new Container();
$container->set("log", "graychen\container\\tests\Fixtures\Log");
$log=$container->get("log", array("setString"));

直接传入实例化的对象的注册

 $container = new Container();
 $container->offsetSet("log", new Log());
 $container->offsetGet("log")

容器中的判断语句

判断容器中是否存在这个类

$container->offsetExists("log")

去除容器中的示例

$container->offsetUnset("write")

The Versions

22/02 2018

dev-master

9999999-dev

a container for interface and container

  Sources   Download

MIT

The Development Requires

by Avatar Graychen

22/02 2018

v1.0.0

1.0.0.0

a container for interface and container

  Sources   Download

MIT

The Development Requires

by Avatar Graychen

22/02 2018

dev-testing

dev-testing

a container for interface and container

  Sources   Download

MIT

The Development Requires

by Avatar Graychen