绑定
简单绑定<br>
$this->app-><b>bind</b>('HelpSpot\API', function ($app) {<br> return new \HelpSpot\API($app->make('HttpClient'));<br>});
绑定一个单例
$this->app-><b>singleton</b>('HelpSpot\API', function ($app) {<br> return new \HelpSpot\API($app->make('HttpClient'));<br>});
绑定实例
$api = new \HelpSpot\API(new HttpClient);<br>$this->app-><b>instance</b>('HelpSpot\API', $api);
绑定接口到实现
$this->app-><b>bind</b>(<br> 'App\Contracts\EventPusher',<br> 'App\Services\RedisEventPusher'<br>);
解析
make
$api = $this->app->make('HelpSpot\API');
resolve
$api = resolve('HelpSpot\API');
事件
$this->app->resolving(function ($object, $app) {<br> // 当容器解析任何类型的对象时调用...<br>});<br><br>$this->app->resolving(\HelpSpot\API::class, function ($api, $app) {<br> // 当容器解析类型为 "HelpSpot\API" 的对象时调用...<br>});