1 Service 容器: 利用了 反射服务。
2 使用 $this->app->bind(); 方法进行绑定,然后利用匿名函数执行。
function($app){return new HelpSpot\API('$app['HttpClient']');}
3 利用
this−>app−>singleton();方法进行绑定。4利用
this->app->instance();方式进行 绑定一个 instances 实例。
5 绑定接口到组件 $this->app->bind('App\Contracts\EventPusher','App\Services\RedisEventPusher');
进行
6 支持上下文绑定
$this->app->when('App\Handler\Commands\CreateOrderHandler')
->needs('App\Contracts\EventPusher')
->give('App\Services\PubNubEventPuseher');
// 或者可以使用匿名函数
->give(function(){
//TODO
});
7 支持绑定后标签定义,跟别名应该差不多。
8 $this->app->tag(['SpeedReport',''],'reports');
9 解决方案$this->app->make(‘FooBar’);
10 容器事件,添加监听事件。