refactor: reorganize to standard PHP structure

- Moved /lib → /src (PHP source code)
- Moved /includes → /public/includes (main site templates)
- Admin section remains self-contained in /public/admin with its own /inc
- Updated all require/include paths across codebase
- Updated config/bootstrap.php, justfile, tests, docs
- All tests passing 

Structure now follows PHP best practices:
  /config      - Configuration files
  /database    - SQLite database + schema
  /docs        - Documentation (intact)
  /nginx       - Server config (intact)
  /public      - Web-accessible files (entry point)
    /admin     - Self-contained admin interface
    /assets    - CSS, fonts, icons
    /includes  - Main site templates (header/footer)
  /scripts     - Deployment scripts (intact)
  /src         - PHP source classes (Database, AdminAuth, RateLimit)
  /tests       - Test suites
This commit is contained in:
Théophile Gervreau-Mercier
2026-02-12 12:11:16 +01:00
parent 0b650cd3e7
commit 0e4921583e
26 changed files with 40 additions and 42 deletions

55
src/config.php Normal file
View File

@@ -0,0 +1,55 @@
<?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__ . '/..');
// Test database (used in development)
define('DB_TEST_PATH', DB_ROOT . '/database/test.db');
// Production database (used on server)
define('DB_PROD_PATH', DB_ROOT . '/database/posterg.db');
/**
* Determine which database to use
* Checks environment variable DB_ENV, defaults to auto-detection
*
* Set DB_ENV in your environment:
* - export DB_ENV=test # Force test database
* - export DB_ENV=prod # Force production database
*
* Auto-detection logic:
* - If test.db exists, use it (development)
* - Otherwise use posterg.db (production)
*/
function getDatabasePath() {
// Allow explicit override via environment variable
$env = getenv('DB_ENV');
if ($env === 'test') {
return DB_TEST_PATH;
}
if ($env === 'prod') {
return DB_PROD_PATH;
}
// Auto-detect: prefer test database if it exists
if (file_exists(DB_TEST_PATH)) {
return DB_TEST_PATH;
}
// Default to production database
return DB_PROD_PATH;
}
/**
* Check if running in test/development mode
*/
function isTestMode() {
return getDatabasePath() === DB_TEST_PATH;
}