3 namespace BookStack\Providers;
5 use BookStack\Actions\ActivityLogger;
6 use BookStack\Auth\Access\SocialAuthService;
7 use BookStack\Entities\Models\Book;
8 use BookStack\Entities\Models\Bookshelf;
9 use BookStack\Entities\Models\Chapter;
10 use BookStack\Entities\Models\Page;
11 use BookStack\Exceptions\BookStackExceptionHandlerPage;
12 use BookStack\Settings\SettingService;
13 use BookStack\Util\CspService;
14 use GuzzleHttp\Client;
15 use Illuminate\Contracts\Foundation\ExceptionRenderer;
16 use Illuminate\Database\Eloquent\Relations\Relation;
17 use Illuminate\Support\Facades\Schema;
18 use Illuminate\Support\Facades\URL;
19 use Illuminate\Support\ServiceProvider;
20 use Psr\Http\Client\ClientInterface as HttpClientInterface;
22 class AppServiceProvider extends ServiceProvider
25 * Custom container bindings to register.
29 ExceptionRenderer::class => BookStackExceptionHandlerPage::class,
33 * Custom singleton bindings to register.
36 public $singletons = [
37 'activity' => ActivityLogger::class,
38 SettingService::class => SettingService::class,
39 SocialAuthService::class => SocialAuthService::class,
40 CspService::class => CspService::class,
44 * Bootstrap any application services.
48 public function boot()
51 $appUrl = config('app.url');
53 $isHttps = (strpos($appUrl, 'https://') === 0);
54 URL::forceRootUrl($appUrl);
55 URL::forceScheme($isHttps ? 'https' : 'http');
58 // Allow longer string lengths after upgrade to utf8mb4
59 Schema::defaultStringLength(191);
61 // Set morph-map for our relations to friendlier aliases
62 Relation::enforceMorphMap([
63 'bookshelf' => Bookshelf::class,
64 'book' => Book::class,
65 'chapter' => Chapter::class,
66 'page' => Page::class,
71 * Register any application services.
75 public function register()
77 $this->app->bind(HttpClientInterface::class, function ($app) {