introduce dotenv parsing for setup.php

This adds the notion of a project directory. This is the directory
that holds all necessary files for one specific installation of
Nominatim. Dotenv looks for an .env file in this directory and
adds it to the global environment together with the defaults from
Nominatim's data directory.

Add's symfony's dotenv library as a new dependency.
This commit is contained in:
Sarah Hoffmann
2020-12-15 13:57:34 +01:00
parent ac116980ac
commit 25bdd7c6d9
3 changed files with 20 additions and 2 deletions

View File

@@ -1,5 +1,23 @@
<?php
require('Symfony/Component/Dotenv/autoload.php');
function loadSettings($sProjectDir)
{
if (!$sProjectDir) {
$sProjectDir = getcwd();
}
@define('CONST_InstallDir', $sProjectDir);
$dotenv = new \Symfony\Component\Dotenv\Dotenv();
if (file_exists($sProjectDir.'/.env')) {
$dotenv->load($sProjectDir.'/.env');
}
$dotenv->load(CONST_DataDir.'/settings/env.defaults');
}
function fail($sError, $sUserError = false)
{
if (!$sUserError) $sUserError = $sError;