1 <?php namespace BookStack\Providers;
4 use BookStack\Entities\Models\Book;
5 use BookStack\Entities\Models\Bookshelf;
6 use BookStack\Entities\BreadcrumbsViewComposer;
7 use BookStack\Entities\Models\Chapter;
8 use BookStack\Entities\Models\Page;
9 use BookStack\Settings\Setting;
10 use BookStack\Settings\SettingService;
11 use Illuminate\Contracts\Cache\Repository;
12 use Illuminate\Database\Eloquent\Relations\Relation;
13 use Illuminate\Support\Facades\View;
14 use Illuminate\Support\ServiceProvider;
18 class AppServiceProvider extends ServiceProvider
21 * Bootstrap any application services.
25 public function boot()
28 $appUrl = config('app.url');
30 $isHttps = (strpos($appUrl, 'https://') === 0);
31 URL::forceRootUrl($appUrl);
32 URL::forceScheme($isHttps ? 'https' : 'http');
35 // Custom blade view directives
36 Blade::directive('icon', function ($expression) {
37 return "<?php echo icon($expression); ?>";
40 // Allow longer string lengths after upgrade to utf8mb4
41 Schema::defaultStringLength(191);
43 // Set morph-map due to namespace changes
45 'BookStack\\Bookshelf' => Bookshelf::class,
46 'BookStack\\Book' => Book::class,
47 'BookStack\\Chapter' => Chapter::class,
48 'BookStack\\Page' => Page::class,
52 View::composer('partials.breadcrumbs', BreadcrumbsViewComposer::class);
56 * Register any application services.
60 public function register()
62 $this->app->singleton(SettingService::class, function ($app) {
63 return new SettingService($app->make(Setting::class), $app->make(Repository::class));