update
This commit is contained in:
@@ -6,8 +6,22 @@ ini_set('display_errors', '1');
|
|||||||
ini_set('display_startup_errors', '1');
|
ini_set('display_startup_errors', '1');
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
require_once __DIR__ . '/settings.php';
|
// Pick config set: first try root files, otherwise fall back to env dir (prod/staging/...)
|
||||||
require_once __DIR__ . '/domaindata.php';
|
$appEnvFromEnv = getenv('APP_ENV') ?: 'prod';
|
||||||
|
$envDir = rtrim(__DIR__, '/\\') . '/' . $appEnvFromEnv;
|
||||||
|
|
||||||
|
foreach (['settings.php', 'domaindata.php'] as $cfgFile) {
|
||||||
|
$rootPath = __DIR__ . '/' . $cfgFile;
|
||||||
|
$envPath = $envDir . '/' . $cfgFile;
|
||||||
|
|
||||||
|
if (file_exists($rootPath)) {
|
||||||
|
require_once $rootPath;
|
||||||
|
} elseif (file_exists($envPath)) {
|
||||||
|
require_once $envPath;
|
||||||
|
} else {
|
||||||
|
throw new \RuntimeException("Missing required config file: $cfgFile (looked for $rootPath or $envPath)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Environment: staging|prod|local (example)
|
// Environment: staging|prod|local (example)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
require_once __DIR__ . '/fileload.php';
|
// boot application (config, autoload, services)
|
||||||
|
require_once __DIR__ . '/../config/fileload.php';
|
||||||
|
|
||||||
$uriPath = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/';
|
$uriPath = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/';
|
||||||
$uriPath = preg_replace('~/{2,}~', '/', $uriPath);
|
$uriPath = preg_replace('~/{2,}~', '/', $uriPath);
|
||||||
|
|||||||
@@ -28,8 +28,10 @@ final class Config
|
|||||||
|
|
||||||
$dbEnabled = defined('APP_DB_ENABLED') ? (bool) APP_DB_ENABLED : false;
|
$dbEnabled = defined('APP_DB_ENABLED') ? (bool) APP_DB_ENABLED : false;
|
||||||
|
|
||||||
$dbFile = rtrim($configDir, '/\\') . DIRECTORY_SEPARATOR . 'db.php';
|
$dbFileRoot = rtrim($configDir, '/\\') . DIRECTORY_SEPARATOR . 'db.php';
|
||||||
$db = file_exists($dbFile) ? (array) require $dbFile : [];
|
$dbFileEnv = rtrim($configDir, '/\\') . DIRECTORY_SEPARATOR . $env . DIRECTORY_SEPARATOR . 'db.php';
|
||||||
|
$dbFile = file_exists($dbFileRoot) ? $dbFileRoot : (file_exists($dbFileEnv) ? $dbFileEnv : null);
|
||||||
|
$db = $dbFile ? (array) require $dbFile : [];
|
||||||
|
|
||||||
return new self(
|
return new self(
|
||||||
env: $env,
|
env: $env,
|
||||||
|
|||||||
Reference in New Issue
Block a user