Add function "updateEnvFile" to save settings in .env file

pull/2487/head
jmontoyaa 7 years ago
parent c093976188
commit 23fc23e63d
  1. 9
      main/install/index.php
  2. 11
      main/install/install.lib.php

@ -782,8 +782,6 @@ if (@$_POST['step2']) {
$manager->getConnection()->executeQuery($sql);
$envFile = api_get_path(SYS_PATH).'.env';
$contents = file_get_contents($envFile);
$params = [
'{{DATABASE_HOST}}' => $dbHostForm,
'{{DATABASE_PORT}}' => $dbPortForm,
@ -793,10 +791,8 @@ if (@$_POST['step2']) {
'{{APP_INSTALLED}}' => 1,
'{{APP_ENCRYPT_METHOD}}' => $encryptPassForm
];
$contents = str_replace(array_keys($params), array_values($params), $contents);
file_put_contents($envFile, $contents);
(new Dotenv())->load(api_get_path(SYS_PATH).'.env');
updateEnvFile($params);
(new Dotenv())->load($envFile);
$kernel = new Kernel('dev', true);
$application = new Application($kernel);
@ -810,7 +806,6 @@ if (@$_POST['step2']) {
$kernel->boot();
$doctrine = $kernel->getContainer()->get('doctrine');
$manager = $doctrine->getManager();
$sysPath = api_get_path(SYS_PATH);
finishInstallation(
$manager,

@ -2722,6 +2722,17 @@ function fixIds(EntityManager $em)
}
}
/**
* @param array $params
*/
function updateEnvFile($params)
{
$envFile = api_get_path(SYS_PATH).'.env';
$contents = file_get_contents($envFile);
$contents = str_replace(array_keys($params), array_values($params), $contents);
file_put_contents($envFile, $contents);
}
/**
*
* After the schema was created (table creation), the function adds

Loading…
Cancel
Save