update config
This commit is contained in:
@@ -5,6 +5,23 @@ mysqli_report(MYSQLI_REPORT_OFF);
|
|||||||
|
|
||||||
if (!function_exists('loadDatabaseConfig')) {
|
if (!function_exists('loadDatabaseConfig')) {
|
||||||
function loadDatabaseConfig(): array {
|
function loadDatabaseConfig(): array {
|
||||||
|
// Load .env if exists
|
||||||
|
$envFile = dirname(__DIR__, 2) . '/.env';
|
||||||
|
if (file_exists($envFile)) {
|
||||||
|
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
if (strpos(trim($line), '#') === 0) continue;
|
||||||
|
list($name, $value) = explode('=', $line, 2);
|
||||||
|
$name = trim($name);
|
||||||
|
$value = trim($value);
|
||||||
|
if (!array_key_exists($name, $_SERVER) && !array_key_exists($name, $_ENV)) {
|
||||||
|
putenv(sprintf('%s=%s', $name, $value));
|
||||||
|
$_ENV[$name] = $value;
|
||||||
|
$_SERVER[$name] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$config = [
|
$config = [
|
||||||
'host' => getenv('DB_HOST') ?: '127.0.0.1',
|
'host' => getenv('DB_HOST') ?: '127.0.0.1',
|
||||||
'user' => getenv('DB_USER') ?: 'root',
|
'user' => getenv('DB_USER') ?: 'root',
|
||||||
|
|||||||
Reference in New Issue
Block a user