love_php/app/Providers/SmsServiceProvider.php

41 lines
697 B
PHP
Raw Normal View History

2026-04-02 09:20:51 +08:00
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Services\SmsService;
class SmsServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('sms',function(){
return new SmsService();
});
//使用bind绑定实例到接口以便依赖注入
$this->app->bind('App\Contracts\SmsContract',function(){
return new SmsService();
});
}
}