65 lines
788 B
PHP
65 lines
788 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
use App\Services\LiveService;
|
|
|
|
class LiveServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap the application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Register the application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @author LaravelAcademy.org
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
//使用singleton绑定单例
|
|
|
|
$this->app->singleton('live',function(){
|
|
|
|
return new LiveService();
|
|
|
|
});
|
|
|
|
//使用bind绑定实例到接口以便依赖注入
|
|
|
|
$this->app->bind('App\Contracts\LiveContract',function(){
|
|
|
|
return new LiveService();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} |