From 8bae8a43f9a43351f7768e4e3af52a7e48253274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Thu, 24 Aug 2017 14:29:06 +0200 Subject: [PATCH] FEATURE: add SITE_URL into installer --- app/Console/Commands/InstallCMS.php | 26 ++++++++++++++++++++++ app/Console/Commands/Modules/CreateNew.php | 3 +++ 2 files changed, 29 insertions(+) diff --git a/app/Console/Commands/InstallCMS.php b/app/Console/Commands/InstallCMS.php index 8561da9e..005db65c 100644 --- a/app/Console/Commands/InstallCMS.php +++ b/app/Console/Commands/InstallCMS.php @@ -25,6 +25,7 @@ class InstallCMS extends Command */ public function handle() { + // check and eventualy create .env file if (!file_exists(base_path('.env'))) { $this->createEnv(); } @@ -54,8 +55,10 @@ class InstallCMS extends Command } $this->line('Chmod changed'); + // generate APP_KEY in .env $this->call('key:generate'); + // create user $this->line('Creating admin user...'); do { $email = $this->ask('E-mail for admin user'); @@ -66,6 +69,12 @@ class InstallCMS extends Command $this->line('All done. CMS should be prepared.'); } + /** + * Insert value into .env config file + * + * @param $envConstant + * @param $value + */ private function setEnvConstant($envConstant, $value) { $content = file_get_contents(base_path('.env')); @@ -73,6 +82,9 @@ class InstallCMS extends Command file_put_contents(base_path('.env'), $content); } + /** + * Create .env file with all needed constants + */ private function createEnv() { \File::copy(base_path('.env.example'), base_path('.env')); @@ -105,8 +117,22 @@ class InstallCMS extends Command $this->setEnvConstant($constant, $value); } + + // set app url + do { + $url = $this->ask('Application URL'); + $url = trim($url, ' /'); + } while (empty($url)); + $this->setEnvConstant('SITE_URL', $url); + $this->setEnvConstant('UPLOAD_URL', $url . '/public/uploads'); + $this->setEnvConstant('THUMBNAIL_URL', $url . '/public/uploads/thumbnails'); } + /** + * Recursively change chmod to 777 in given directory + * + * @param $directory + */ private function changeChmod($directory) { @chmod($directory, 0777); diff --git a/app/Console/Commands/Modules/CreateNew.php b/app/Console/Commands/Modules/CreateNew.php index 69bfebd8..7b70e365 100644 --- a/app/Console/Commands/Modules/CreateNew.php +++ b/app/Console/Commands/Modules/CreateNew.php @@ -64,6 +64,9 @@ class CreateNew extends Command } $this->info('Module successfully created.'); + + $this->call('module:install', ['name' => $this->moduleName]); + } /**