AppServiceProvider.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace App\Base\Providers;
  3. use App\Activity\Providers\ActivityServiceProvider;
  4. use App\Admin\Providers\AdminServiceProvider;
  5. use App\Api\Providers\ApiServiceProvider;
  6. use App\Attachment\Providers\AttachmentServiceProvider;
  7. use App\Base\Facades\AliPayFacade;
  8. use App\Base\Facades\ApiSysUserFacade;
  9. use App\Base\Facades\ObsFacade;
  10. use App\Base\Facades\PaypalPayFacade;
  11. use App\Base\Facades\PinYinFacade;
  12. use App\Base\Facades\SmsFacade;
  13. use App\Base\Facades\UploadFacade;
  14. use App\Base\Facades\WechatPayFacade;
  15. use App\Base\Models\ComOssETagModel;
  16. use App\Base\Services\AliPayService;
  17. use App\Base\Services\ApiSysUserService;
  18. use App\Base\Services\ObsService;
  19. use App\Base\Services\PaypalPayService;
  20. use App\Base\Services\PinYinService;
  21. use App\Base\Services\SmsService;
  22. use App\Base\Services\UploadService;
  23. use App\Base\Services\WechatPayService;
  24. use App\Basic\Providers\BasicServiceProvider;
  25. use App\Blog\Providers\BlogServiceProvider;
  26. use App\Crontab\Providers\TaskServiceProvider;
  27. use App\Doc\Providers\DocServiceProvider;
  28. use App\Expert\Providers\ExpertServiceProvider;
  29. use App\Form\Providers\FormServiceProvider;
  30. use App\Live\Providers\LiveServiceProvider;
  31. use App\Log\Providers\LogProvider;
  32. use App\Order\Providers\OrderServiceProvider;
  33. use App\RedisDeposit\Providers\RedisDepositServiceProvider;
  34. use App\Sys\Providers\SysServiceProvider;
  35. use App\TencentCloud\Providers\TencentServiceProvider;
  36. use App\User\Providers\UserServiceProvider;
  37. use App\Web\Providers\WebServiceProvider;
  38. use Illuminate\Redis\RedisServiceProvider;
  39. use Intervention\Image\ImageServiceProvider;
  40. use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
  41. class AppServiceProvider extends ServiceProvider
  42. {
  43. //路由文件名
  44. protected $routes = 'routes.php';
  45. public function boot()
  46. {
  47. //sql打印 不提交
  48. /* \DB::listen(function ($query) {
  49. $sql = array_reduce($query->bindings, function($sql, $binding) {
  50. return preg_replace('/\?/', is_numeric($binding) ? $binding : sprintf("'%s'", $binding), $sql, 1);
  51. }, $query->sql);
  52. \Log::info($sql);
  53. });*/
  54. //自动载入路由
  55. $func = new \ReflectionClass(get_class($this));
  56. $path = str_replace($func->getShortName() . '.php', '', $func->getFileName());
  57. $routesFile = $path . '../' . $this->routes;
  58. if (file_exists($routesFile)) {
  59. require $routesFile;
  60. }
  61. if (! isset($this->app['blade.compiler'])) {
  62. $this->app['view'];
  63. }
  64. parent::boot();
  65. }
  66. /**
  67. * 注册
  68. */
  69. public function register()
  70. {
  71. //基础服务
  72. $this->registerBaseService();
  73. //文档模块
  74. $this->app->register(DocServiceProvider::class);
  75. // 接口模块
  76. $this->app->register(ApiServiceProvider::class);
  77. //注册定时任务模块
  78. $this->app->register(TaskServiceProvider::class);
  79. $this->app->register(BasicServiceProvider::class);
  80. }
  81. // 注册基础服务
  82. public function registerBaseService()
  83. {
  84. // redis服务
  85. $this->app->register(RedisServiceProvider::class);
  86. // 短信服务
  87. // $this->app->register(AliyunsmsServiceProvider::class);
  88. // 授权验证
  89. $this->app->register(AuthServiceProvider::class);
  90. }
  91. }