app->call('App\Http\Middleware\DetectLanguagePrefer@detect'); $this->checkFilePermissions(); $this->checkDatabaseConnection(); // skip the installation check when setup or under CLI if (!$request->is('setup*') && PHP_SAPI != "cli") { $this->checkInstallation(); } } protected function checkFilePermissions() { // check dotenv if (!file_exists(base_path('.env'))) { throw new PrettyPageException(trans('setup.file.no-dot-env'), -1); } // check permissions of storage path if (!is_writable(storage_path())) { throw new PrettyPageException(trans('setup.permissions.storage'), -1); } if (!SetupController::checkDirectories()) { throw new PrettyPageException(trans('setup.file.permission-error'), -1); } } protected function checkDatabaseConnection() { try { // check database config Database::prepareConnection(); } catch (\Exception $e) { throw new PrettyPageException( trans('setup.database.connection-error', ['msg' => $e->getMessage()]), $e->getCode() ); } } protected function checkInstallation() { // redirect to setup wizard if (!SetupController::checkTablesExist()) { return redirect('/setup')->send(); } if (Utils::versionCompare(config('app.version'), option('version', ''), '>')) { return redirect('/setup/update')->send(); } return true; } /** * Register any application services. * * @return void */ public function register() { View::addExtension('tpl', 'blade'); $this->app->singleton('options', OptionRepository::class); $this->app->singleton('database', Database::class); } }