From 6659803a218a3a8dc30a282146c9a87af5322e7f Mon Sep 17 00:00:00 2001 From: Jeramy Simpson Date: Tue, 24 Mar 2015 09:54:49 +1000 Subject: [PATCH] Update Config Settings to use .env Also has a minor change to the install and upgrade function to work with L5. --- app/Http/Controllers/AppController.php | 68 +++++++++++++++++++++----- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php index 71263647f1..b22be9510f 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/AppController.php @@ -73,27 +73,60 @@ class AppController extends BaseController fwrite($fp, $content); fclose($fp); - $configDir = base_path().'/config/production'; + /*$configDir = base_path().'/config/production'; if (!file_exists($configDir)) { mkdir($configDir); + }*/ + + // TODO: Please test this!!!!!!!!!!! + + // == ENV Settings (Production) == // + + $env_config = ''; + $settings = ['app' => $app, 'database' => $database, 'mail' => $mail]; + + // Save each config area to $env varible + foreach ($settings as $key => $config) { + + // Write a nice Comment to lay out each config area + $env_config .= "# " . $key . " Settings \n"; + + // For Each config varible : Write to env + foreach ($config as $name => $value) { + $env_config .= strtoupper($name) . '=' . $value . "\n"; + } } - foreach (['app' => $app, 'database' => $database, 'mail' => $mail] as $key => $config) { - $content = 'run(); + // == END DB Migrate & Seed == // + + $account = $this->accountRepo->create(); $user = $account->users()->first(); @@ -156,12 +189,16 @@ class AppController extends BaseController } } + // QUSTION: Does this actually get used??? public function install() { if (!Utils::isNinja() && !Utils::isDatabaseSetup()) { try { - Artisan::call('migrate'); - Artisan::call('db:seed'); + // DB Migrate & Seed + // I Really don't want to do it this way but its the best I've found so far. See Above. + $process = new \Symfony\Component\Process\Process('cd ' . base_path() . ' && php artisan migrate --seed'); + $process->run(); + } catch (Exception $e) { Response::make($e->getMessage(), 500); } @@ -174,7 +211,12 @@ class AppController extends BaseController { if (!Utils::isNinja()) { try { - Artisan::call('migrate'); + // DB Migrate & Seed + // I Really don't want to do it this way but its the best I've found so far. See Above. + $process = new \Symfony\Component\Process\Process('cd ' . base_path() . ' && php artisan migrate'); + $process->run(); + + // Artisan::call('migrate'); Cache::flush(); } catch (Exception $e) { Response::make($e->getMessage(), 500);