mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
feat: extract MediaController, wire into Dispatcher, delete media.php
This commit is contained in:
49
config/config.php
Normal file
49
config/config.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Configuration for Post-ERG thesis database
|
||||
* Central location for database paths and environment settings
|
||||
*/
|
||||
|
||||
// Database paths relative to repository root
|
||||
define('DB_ROOT', __DIR__ . '/..');
|
||||
|
||||
// Local dev database (php -S, never committed)
|
||||
define('DB_TEST_PATH', DB_ROOT . '/storage/test.db');
|
||||
|
||||
// Production database (nginx/php-fpm on server)
|
||||
define('DB_PROD_PATH', DB_ROOT . '/storage/posterg.db');
|
||||
|
||||
/**
|
||||
* Determine which database to use.
|
||||
*
|
||||
* - php built-in server (php -S …) → storage/test.db (local dev)
|
||||
* - everything else (nginx/fpm) → storage/posterg.db (production)
|
||||
*
|
||||
* The DB_ENV env-var can still override either way:
|
||||
* DB_ENV=test → force test.db
|
||||
* DB_ENV=prod → force posterg.db
|
||||
*/
|
||||
function getDatabasePath(): string {
|
||||
$env = getenv('DB_ENV');
|
||||
if ($env === 'test') {
|
||||
return DB_TEST_PATH;
|
||||
}
|
||||
if ($env === 'prod') {
|
||||
return DB_PROD_PATH;
|
||||
}
|
||||
|
||||
// Auto-detect: php built-in CLI server == local development
|
||||
if (php_sapi_name() === 'cli-server') {
|
||||
return DB_TEST_PATH;
|
||||
}
|
||||
|
||||
return DB_PROD_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if running in local dev mode
|
||||
*/
|
||||
function isTestMode(): bool {
|
||||
return getDatabasePath() === DB_TEST_PATH;
|
||||
}
|
||||
Reference in New Issue
Block a user