OAuthServiceProvider.php 946 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Module\OAuth;
  3. use Illuminate\Support\ServiceProvider;
  4. use Illuminate\Support\Facades\View;
  5. use Illuminate\Support\ViewErrorBag;
  6. use App\Module\OAuth\Middleware\StartSession;
  7. class OAuthServiceProvider extends ServiceProvider
  8. {
  9. /**
  10. * 注册服务
  11. */
  12. public function register()
  13. {
  14. // 注册中间件
  15. $this->app['router']->aliasMiddleware('oauth.session', StartSession::class);
  16. }
  17. /**
  18. * 引导服务
  19. */
  20. public function boot()
  21. {
  22. // 注册视图命名空间
  23. $this->loadViewsFrom(__DIR__ . '/resources/views', 'oauth');
  24. // 加载路由
  25. $this->loadRoutesFrom(__DIR__ . '/routes.php');
  26. // 发布资源文件
  27. $this->publishes([
  28. __DIR__ . '/resources/assets' => public_path('modules/oauth'),
  29. ], 'oauth-assets');
  30. // 共享视图变量
  31. View::share('errors', new ViewErrorBag);
  32. }
  33. }