project container
IOC服务容器管理组件
badtomcat/container
IOC服务容器管理组件
- Wednesday, December 20, 2017
- by badtomcat
- Repository
- 0 Watchers
- 0 Stars
- 21 Installations
- PHP
- 1 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 5 % Grown
container
IOC服务容器管理组件, (*1)
composer require badtomcat/container, (*2)
$test = new \Badtomcat\Container();
$test->bind("foo",function (cls $ins)
{
return $ins;
});
$this->assertEquals('foo',$test->make('foo')->bar);
$test->instance("value",123);
$this->assertEquals(123,$test->make('value'));
$this->assertTrue($test->bound("foo"));
$test->bind("bar",cls::class);
$this->assertInstanceOf(cls::class,$test->make("bar"));
[] 操作符执行的是make和bind, (*3)