refactor(config): remove runtime config files and centralize route/bootstrap
This commit is contained in:
@@ -64,31 +64,6 @@ if (!defined('APP_LOCALES')) {
|
||||
define('APP_LOCALES', $envList('APP_LOCALES', ['de', 'en']));
|
||||
}
|
||||
|
||||
if (!defined('APP_ROUTE_DEFINITIONS')) {
|
||||
$routesFile = __DIR__ . '/routes.php';
|
||||
$routeDefinitions = is_file($routesFile) ? include $routesFile : [];
|
||||
if (!is_array($routeDefinitions)) {
|
||||
$routeDefinitions = [];
|
||||
}
|
||||
define('APP_ROUTE_DEFINITIONS', $routeDefinitions);
|
||||
}
|
||||
|
||||
if (!defined('APP_PUBLIC_PATHS')) {
|
||||
$publicPaths = [];
|
||||
foreach (APP_ROUTE_DEFINITIONS as $route) {
|
||||
if (!empty($route['public'])) {
|
||||
$path = trim((string) ($route['path'] ?? ''));
|
||||
if ($path !== '') {
|
||||
$publicPaths[] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$publicPaths) {
|
||||
throw new RuntimeException('No public routes configured in config/routes.php');
|
||||
}
|
||||
define('APP_PUBLIC_PATHS', array_values(array_unique($publicPaths)));
|
||||
}
|
||||
|
||||
date_default_timezone_set(APP_TIMEZONE);
|
||||
|
||||
Router::$baseUrl = '/'; // default: '/'
|
||||
|
||||
Reference in New Issue
Block a user