1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Update Config Settings to use .env

Also has a minor change to the install and upgrade function to work with L5.
This commit is contained in:
Jeramy Simpson 2015-03-24 09:54:49 +10:00
parent cf5adfad25
commit 6659803a21

View File

@ -73,27 +73,60 @@ class AppController extends BaseController
fwrite($fp, $content); fwrite($fp, $content);
fclose($fp); fclose($fp);
$configDir = base_path().'/config/production'; /*$configDir = base_path().'/config/production';
if (!file_exists($configDir)) { if (!file_exists($configDir)) {
mkdir($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) { // Check Config Settings !empty
$content = '<?php return '.var_export($config, true).';'; if(empty($env_config)){
$fp = fopen(base_path()."/config/production/{$key}.php", 'w'); dd('ERROR: No Config settings saved to content var');
fwrite($fp, $content); }
// Write Config Settings
$fp = fopen(base_path()."/.env", 'w');
fwrite($fp, $env_config);
fclose($fp); fclose($fp);
}
// Laravel 5 thows an error when performing these calls // == END ENV Settings == //
// See: https://laracasts.com/discuss/channels/general-discussion/l5-artisancall-issue
// Artisan::call('migrate');
// Artisan::call('db:seed'); // == DB Migrate & Seed == //
/* Laravel 5 thows an error when performing these calls
* See: https://laracasts.com/discuss/channels/general-discussion/l5-artisancall-issue
Artisan::call('migrate');
Artisan::call('db:seed');
*/
// I Really don't want to do it this way but its the best I've found so far. // I Really don't want to do it this way but its the best I've found so far.
$process = new \Symfony\Component\Process\Process('cd ' . base_path() . ' && php artisan migrate --seed'); $process = new \Symfony\Component\Process\Process('cd ' . base_path() . ' && php artisan migrate --seed');
$process->run(); $process->run();
// == END DB Migrate & Seed == //
$account = $this->accountRepo->create(); $account = $this->accountRepo->create();
$user = $account->users()->first(); $user = $account->users()->first();
@ -156,12 +189,16 @@ class AppController extends BaseController
} }
} }
// QUSTION: Does this actually get used???
public function install() public function install()
{ {
if (!Utils::isNinja() && !Utils::isDatabaseSetup()) { if (!Utils::isNinja() && !Utils::isDatabaseSetup()) {
try { try {
Artisan::call('migrate'); // DB Migrate & Seed
Artisan::call('db: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) { } catch (Exception $e) {
Response::make($e->getMessage(), 500); Response::make($e->getMessage(), 500);
} }
@ -174,7 +211,12 @@ class AppController extends BaseController
{ {
if (!Utils::isNinja()) { if (!Utils::isNinja()) {
try { 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(); Cache::flush();
} catch (Exception $e) { } catch (Exception $e) {
Response::make($e->getMessage(), 500); Response::make($e->getMessage(), 500);