Files
Woles-Framework/public/index.php

55 lines
1.7 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* Woles Framework v1.0
* Entry Point
*/
// Enable error reporting for development
if (getenv('APP_DEBUG') === 'true' || getenv('APP_ENV') === 'development') {
error_reporting(E_ALL);
ini_set('display_errors', 1);
}
// Load Composer autoloader
require_once __DIR__ . '/../vendor/autoload.php';
// Load helper functions
require_once __DIR__ . '/../app/helpers.php';
// Load environment variables
if (file_exists(__DIR__ . '/../.env')) {
$lines = file(__DIR__ . '/../.env', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
if (strpos($line, '=') !== false && strpos($line, '#') !== 0) {
list($key, $value) = explode('=', $line, 2);
$key = trim($key);
$value = trim($value);
putenv("$key=$value");
$_ENV[$key] = $value;
}
}
}
// Initialize and run the application
try {
$bootstrap = new App\Core\Bootstrap();
$bootstrap->run();
} catch (Throwable $e) {
// Log error
error_log("Woles Error: " . $e->getMessage() . " in " . $e->getFile() . ":" . $e->getLine());
// Show error page
http_response_code(500);
if (getenv('APP_DEBUG') === 'true') {
echo "<h1>Woles Framework Error</h1>";
echo "<p><strong>Message:</strong> " . htmlspecialchars($e->getMessage()) . "</p>";
echo "<p><strong>File:</strong> " . htmlspecialchars($e->getFile()) . "</p>";
echo "<p><strong>Line:</strong> " . $e->getLine() . "</p>";
echo "<pre>" . htmlspecialchars($e->getTraceAsString()) . "</pre>";
} else {
echo "<h1>Internal Server Error</h1>";
echo "<p>Something went wrong. Please try again later.</p>";
}
}