Ajouter src/config.php
This commit is contained in:
21
src/config.php
Normal file
21
src/config.php
Normal 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',
|
||||
];
|
||||
Reference in New Issue
Block a user