3 namespace BookStack\Providers;
6 use BookStack\Auth\Access\LoginService;
7 use BookStack\Auth\Access\SocialAuthService;
8 use BookStack\Entities\BreadcrumbsViewComposer;
9 use BookStack\Entities\Models\Book;
10 use BookStack\Entities\Models\Bookshelf;
11 use BookStack\Entities\Models\Chapter;
12 use BookStack\Entities\Models\Page;
13 use BookStack\Settings\Setting;
14 use BookStack\Settings\SettingService;
15 use Illuminate\Contracts\Cache\Repository;
16 use Illuminate\Database\Eloquent\Relations\Relation;
17 use Illuminate\Support\Facades\View;
18 use Illuminate\Support\ServiceProvider;
19 use Laravel\Socialite\Contracts\Factory as SocialiteFactory;
23 class AppServiceProvider extends ServiceProvider
26 * Bootstrap any application services.
30 public function boot()
33 $appUrl = config('app.url');
35 $isHttps = (strpos($appUrl, 'https://') === 0);
36 URL::forceRootUrl($appUrl);
37 URL::forceScheme($isHttps ? 'https' : 'http');
40 // Custom blade view directives
41 Blade::directive('icon', function ($expression) {
42 return "<?php echo icon($expression); ?>";
45 // Allow longer string lengths after upgrade to utf8mb4
46 Schema::defaultStringLength(191);
48 // Set morph-map due to namespace changes
50 'BookStack\\Bookshelf' => Bookshelf::class,
51 'BookStack\\Book' => Book::class,
52 'BookStack\\Chapter' => Chapter::class,
53 'BookStack\\Page' => Page::class,
57 View::composer('partials.breadcrumbs', BreadcrumbsViewComposer::class);
61 * Register any application services.
65 public function register()
67 $this->app->singleton(SettingService::class, function ($app) {
68 return new SettingService($app->make(Setting::class), $app->make(Repository::class));
71 $this->app->singleton(SocialAuthService::class, function ($app) {
72 return new SocialAuthService($app->make(SocialiteFactory::class), $app->make(LoginService::class));