Added some hints to setup wizard, new validation rules and readme update

This commit is contained in:
carodej
2020-07-22 09:28:13 +02:00
parent 5c86f4dbb3
commit 35e1262676
6 changed files with 128 additions and 191 deletions

View File

@@ -89,18 +89,30 @@ function add_paragraphs($str)
*
* @param $key
* @param $value
* @return bool
*/
function setEnvironmentValue($key, $value)
function setEnvironmentValue(array $values)
{
$env_path = app()->environmentFilePath();
$envFile = app()->environmentFilePath();
$str = file_get_contents($envFile);
$escaped = preg_quote('=' . env($key), '/');
if (count($values) > 0) {
foreach ($values as $envKey => $envValue) {
$str .= "\n"; // In case the searched variable is in the last line without \n
$keyPosition = strpos($str, "{$envKey}=");
$endOfLinePosition = strpos($str, "\n", $keyPosition);
$oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition);
// If key does not exist, add it
$str = str_replace($oldLine, "{$envKey}={$envValue}", $str);
}
}
$str = substr($str, 0, -1);
if (!file_put_contents($envFile, $str)) return false;
return true;
file_put_contents($env_path, preg_replace(
"/^{$key}{$escaped}/m",
$key . '=' . $value,
file_get_contents($env_path)
));
}
/**