diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-21 20:50:43 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-21 20:50:43 +0100 |
| commit | d1ef15fa39935bfa0420c5ac2b8c269e294c9a6d (patch) | |
| tree | 618158449863123f6b9527b9db6183f8c3ce5c91 /src/app/bootstrap.php | |
| download | camagru-d1ef15fa39935bfa0420c5ac2b8c269e294c9a6d.tar.gz camagru-d1ef15fa39935bfa0420c5ac2b8c269e294c9a6d.zip | |
Initial project scaffold
Set up MVC architecture with front controller, router, autoloader,
database singleton, and Docker Compose stack (Nginx + PHP-FPM + MariaDB).
Includes DB schema, responsive layout, dev tooling (php-cs-fixer,
parallel-lint), and documentation.
Diffstat (limited to 'src/app/bootstrap.php')
| -rw-r--r-- | src/app/bootstrap.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/app/bootstrap.php b/src/app/bootstrap.php new file mode 100644 index 0000000..835615b --- /dev/null +++ b/src/app/bootstrap.php @@ -0,0 +1,42 @@ +<?php + +declare(strict_types=1); +// Application bootstrap: loads .env, registers the autoloader, and configures error reporting. + +session_start(); + +// Load .env +$envFile = dirname(__DIR__, 2) . '/.env'; +if (file_exists($envFile)) { + $lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + foreach ($lines as $line) { + if (str_starts_with(trim($line), '#')) { + continue; + } + $parts = explode('=', $line, 2); + if (count($parts) === 2) { + $key = trim($parts[0]); + $value = trim($parts[1]); + $_ENV[$key] = $value; + putenv("$key=$value"); + } + } +} + +// Autoloader +spl_autoload_register(function (string $class): void { + $prefix = 'App\\'; + if (!str_starts_with($class, $prefix)) { + return; + } + $relative = substr($class, strlen($prefix)); + $file = __DIR__ . '/' . str_replace('\\', '/', $relative) . '.php'; + if (file_exists($file)) { + require $file; + } +}); + +// Error reporting +error_reporting(E_ALL); +ini_set('display_errors', '0'); +ini_set('log_errors', '1'); |
