FEATURE: add SITE_URL into installer

This commit is contained in:
Michal Kváček
2017-08-24 14:29:06 +02:00
parent 0e535c3ed1
commit 8bae8a43f9
2 changed files with 29 additions and 0 deletions
+26
View File
@@ -25,6 +25,7 @@ class InstallCMS extends Command
*/ */
public function handle() public function handle()
{ {
// check and eventualy create .env file
if (!file_exists(base_path('.env'))) { if (!file_exists(base_path('.env'))) {
$this->createEnv(); $this->createEnv();
} }
@@ -54,8 +55,10 @@ class InstallCMS extends Command
} }
$this->line('Chmod changed'); $this->line('Chmod changed');
// generate APP_KEY in .env
$this->call('key:generate'); $this->call('key:generate');
// create user
$this->line('Creating admin user...'); $this->line('Creating admin user...');
do { do {
$email = $this->ask('E-mail for admin user'); $email = $this->ask('E-mail for admin user');
@@ -66,6 +69,12 @@ class InstallCMS extends Command
$this->line('All done. CMS should be prepared.'); $this->line('All done. CMS should be prepared.');
} }
/**
* Insert value into .env config file
*
* @param $envConstant
* @param $value
*/
private function setEnvConstant($envConstant, $value) private function setEnvConstant($envConstant, $value)
{ {
$content = file_get_contents(base_path('.env')); $content = file_get_contents(base_path('.env'));
@@ -73,6 +82,9 @@ class InstallCMS extends Command
file_put_contents(base_path('.env'), $content); file_put_contents(base_path('.env'), $content);
} }
/**
* Create .env file with all needed constants
*/
private function createEnv() private function createEnv()
{ {
\File::copy(base_path('.env.example'), base_path('.env')); \File::copy(base_path('.env.example'), base_path('.env'));
@@ -105,8 +117,22 @@ class InstallCMS extends Command
$this->setEnvConstant($constant, $value); $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) private function changeChmod($directory)
{ {
@chmod($directory, 0777); @chmod($directory, 0777);
@@ -64,6 +64,9 @@ class CreateNew extends Command
} }
$this->info('Module successfully created.'); $this->info('Module successfully created.');
$this->call('module:install', ['name' => $this->moduleName]);
} }
/** /**