54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
// Basic error reporting (keep strict in dev)
|
|
ini_set('display_errors', '1');
|
|
ini_set('display_startup_errors', '1');
|
|
error_reporting(E_ALL);
|
|
|
|
// Pick config set: first try root files, otherwise fall back to env dir (prod/staging/...)
|
|
$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)
|
|
if (!defined('APP_ENV')) {
|
|
define('APP_ENV', 'local');
|
|
}
|
|
|
|
// Asset versioning
|
|
if (!defined('ASSET_VERSION')) {
|
|
define('ASSET_VERSION', 'dev-' . date('Ymd-His'));
|
|
}
|
|
|
|
// Primary domain + URL
|
|
if (!defined('APP_DOMAIN_PRIMARY')) {
|
|
define('APP_DOMAIN_PRIMARY', APP_DOMAIN_NAME);
|
|
}
|
|
if (!defined('APP_URL_PRIMARY')) {
|
|
define('APP_URL_PRIMARY', 'https://' . APP_DOMAIN_PRIMARY);
|
|
}
|
|
|
|
// API base (example)
|
|
if (!defined('APP_API_BASE')) {
|
|
define('APP_API_BASE', 'https://api.' . APP_DOMAIN_PRIMARY);
|
|
}
|
|
|
|
// Feature toggles
|
|
if (!defined('APP_DB_ENABLED')) {
|
|
define('APP_DB_ENABLED', false); // set true to enable DB connection
|
|
}
|