From cbef469e02381e452f3c008b0bb4eb9fd8ecb039 Mon Sep 17 00:00:00 2001 From: KodeStar Date: Tue, 15 Jan 2019 15:23:10 +0000 Subject: [PATCH] Update AppServiceProvider.php --- app/Providers/AppServiceProvider.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 072fa3f7..225a3d61 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -22,8 +22,8 @@ class AppServiceProvider extends ServiceProvider if(!is_file(base_path('.env'))) { copy(base_path('.env.example'), base_path('.env')); - Artisan::call('key:generate'); } + $this->genKey(); if(!is_file(database_path('app.sqlite'))) { // first time setup touch(database_path('app.sqlite')); @@ -117,6 +117,21 @@ class AppServiceProvider extends ServiceProvider } + /** + * Generate app key if missing and .env exists + * + * @return void + */ + public function genKey() + { + if(is_file(base_path('.env'))) { + if(empty(env('APP_KEY'))) { + Artisan::call('key:generate', array('--force' => true, '--no-interaction' => true)); + } + } + } + + /** * Register any application services. *