Ajouter src/config.php

This commit is contained in:
2025-10-30 11:43:40 +00:00
parent 0ff680ed5e
commit 79c722e905

21
src/config.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
$dotenvPath = __DIR__ . '/../.env';
if (file_exists($dotenvPath)) {
$lines = file($dotenvPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
if (strpos(trim($line), '#') === 0) continue;
[$k, $v] = array_map('trim', explode('=', $line, 2) + [null, null]);
if ($k) putenv(sprintf('%s=%s', $k, $v));
}
}
return [
'db' => [
'host' => getenv('DB_HOST') ?: '127.0.0.1',
'dbname' => getenv('DB_NAME') ?: 'cms_simplifie',
'user' => getenv('DB_USER') ?: 'cms_user',
'pass' => getenv('DB_PASS') ?: 'cms_password',
'port' => getenv('DB_PORT') ?: '3306',
'charset' => 'utf8mb4',
],
'base_url' => getenv('BASE_URL') ?: '/public',
];