102 lines
2.5 KiB
PHP
102 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Core\Dipper;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* 注册时加载
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
$this->registerProviders();
|
|
}
|
|
|
|
/**
|
|
* 启动时加载
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
$this->bootConfig();
|
|
$this->bootArch();
|
|
}
|
|
|
|
/**
|
|
* 注册第三方服务
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function registerProviders()
|
|
{
|
|
$this->app->singleton(\Illuminate\Contracts\Debug\ExceptionHandler::class, \Dipper\Foundation\Exceptions\Handler::class);
|
|
$this->app->singleton(\Illuminate\Contracts\Console\Kernel::class, \App\Console\Kernel::class);
|
|
|
|
// Redis
|
|
$this->app->singleton('redis', function ($app) {
|
|
return $app->loadComponent('database', 'Illuminate\Redis\RedisServiceProvider', 'redis');
|
|
});
|
|
|
|
// Mongodb
|
|
$this->app->register(\Jenssegers\Mongodb\MongodbServiceProvider::class);
|
|
|
|
// JWT
|
|
$this->app->register(\Dipper\JWTAuth\JWTAuthServiceProvider::class);
|
|
|
|
// Image
|
|
$this->app->register(\Intervention\Image\ImageServiceProviderLumen::class);
|
|
|
|
// 拼音
|
|
$this->app->register(\Overtrue\LaravelPinyin\ServiceProvider::class);
|
|
|
|
// SMS
|
|
$this->app->singleton('sms', function ($app) {
|
|
return $app->loadComponent('sms', \Dipper\Sms\SmsServiceProvider::class);
|
|
});
|
|
|
|
// flashmessage
|
|
$this->app->singleton('flashmessage', function ($app) {
|
|
return $app->loadComponent('flashmessage', \Dipper\FlashMessage\FlashMessageServiceProvider::class);
|
|
});
|
|
|
|
// excel
|
|
$this->app->singleton('excel', function ($app) {
|
|
return $app->loadComponent('excel', \Maatwebsite\Excel\ExcelServiceProvider::class);
|
|
});
|
|
|
|
// 全局代理
|
|
$this->app->singleton('dipper', function ($app) {
|
|
return new Dipper();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 注册配置
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function bootConfig()
|
|
{
|
|
$this->app->configure('icon');
|
|
$this->app->configure('regex');
|
|
$this->app->configure('filter');
|
|
$this->app->configure('captcha');
|
|
}
|
|
|
|
/**
|
|
* 注册框架
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function bootArch()
|
|
{
|
|
$this->app->register(\Dipper\Foundation\ServiceProvider::class);
|
|
}
|
|
}
|