Commit 3e80ca64 authored by Administrator's avatar Administrator

Update 6 files via Son of Anton

parent ea9f177f
.git
.gitignore
.env.example
docker/
Dockerfile
captain-definition
*.md
.idea/
.vscode/
......
......@@ -51,7 +51,7 @@ RUN chown -R www-data:www-data /var/www/html/storage \
&& chown -R www-data:www-data /var/www/html/public \
&& chmod -R 755 /var/www/html/public
# ── Default environment (overridable via CapRover env vars) ──
# ── Environment (overridable via CapRover env vars) ──
ENV APP_URL=http://localhost
ENV APP_DEBUG=true
ENV APP_ENV=local
......
This diff is collapsed.
<?php
declare(strict_types=1);
require_once __DIR__ . '/../app/Core/Autoloader.php';
\App\Core\Autoloader::register();
/**
* THE CLUB ERP — Front Controller
* All requests route through here.
*/
// Load .env
$envFile = dirname(__DIR__) . '/.env';
// ── Show ALL errors during startup (before ExceptionHandler takes over) ──
error_reporting(E_ALL);
ini_set('display_errors', '1');
// ── Base path resolution ──
define('BASE_PATH', dirname(__DIR__));
// ── Load .env FIRST (before anything else) ──
$envFile = BASE_PATH . '/.env';
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines !== false) {
foreach ($lines as $line) {
$line = trim($line);
if ($line === '' || str_starts_with($line, '#')) {
continue;
}
if (str_contains($line, '=')) {
[$key, $val] = explode('=', $line, 2);
$key = trim($key);
$val = trim($val);
$_ENV[$key] = $val;
$_SERVER[$key] = $val;
foreach ($lines as $line) {
$line = trim($line);
if ($line === '' || str_starts_with($line, '#')) {
continue;
}
if (str_contains($line, '=')) {
[$key, $value] = explode('=', $line, 2);
$key = trim($key);
$value = trim($value);
// Remove surrounding quotes
if ((str_starts_with($value, '"') && str_ends_with($value, '"')) ||
(str_starts_with($value, "'") && str_ends_with($value, "'"))) {
$value = substr($value, 1, -1);
}
$_ENV[$key] = $value;
$_SERVER[$key] = $value;
putenv("{$key}={$value}");
}
}
}
\App\Core\ExceptionHandler::register();
// ── Autoloader ──
require_once BASE_PATH . '/app/Core/Autoloader.php';
App\Core\Autoloader::register();
// ── Helpers (must be loaded before Config since config files call env()) ──
require_once BASE_PATH . '/app/Core/Helpers.php';
$app = \App\Core\App::getInstance();
$app->boot();
// ── Exception handler ──
$exHandler = new App\Core\ExceptionHandler();
$exHandler->register();
$request = \App\Core\Request::capture();
$response = $app->router()->dispatch($request);
$response->send();
\ No newline at end of file
// ── Boot application ──
try {
$app = App\Core\App::getInstance();
$app->boot();
// ── Dispatch request ──
$request = App\Core\Request::capture();
$response = $app->router()->dispatch($request);
$response->send();
} catch (\Throwable $e) {
// If we get here during boot, show the REAL error
$debug = ($_ENV['APP_DEBUG'] ?? 'false') === 'true'
|| (getenv('APP_DEBUG') ?: 'false') === 'true';
if ($debug) {
http_response_code(500);
header('Content-Type: text/html; charset=utf-8');
echo '<html dir="rtl"><head><meta charset="utf-8"><title>Boot Error</title>';
echo '<style>body{font-family:monospace;background:#1a1a2e;color:#e0e0e0;padding:40px;direction:ltr;text-align:left;}';
echo 'h1{color:#ff6b6b;}pre{background:#16213e;padding:20px;border-radius:8px;overflow-x:auto;white-space:pre-wrap;word-wrap:break-word;}';
echo '.info{color:#4ecdc4;margin:10px 0;}</style></head><body>';
echo '<h1>💀 BOOT FAILURE</h1>';
echo '<p class="info">Exception: <strong>' . htmlspecialchars(get_class($e)) . '</strong></p>';
echo '<p class="info">Message: <strong>' . htmlspecialchars($e->getMessage()) . '</strong></p>';
echo '<p class="info">File: ' . htmlspecialchars($e->getFile()) . ':' . $e->getLine() . '</p>';
echo '<h3>Stack Trace:</h3>';
echo '<pre>' . htmlspecialchars($e->getTraceAsString()) . '</pre>';
echo '<h3>Environment Check:</h3>';
echo '<pre>';
echo "DB_HOST: " . (getenv('DB_HOST') ?: ($_ENV['DB_HOST'] ?? 'NOT SET')) . "\n";
echo "DB_PORT: " . (getenv('DB_PORT') ?: ($_ENV['DB_PORT'] ?? 'NOT SET')) . "\n";
echo "DB_NAME: " . (getenv('DB_NAME') ?: ($_ENV['DB_NAME'] ?? 'NOT SET')) . "\n";
echo "DB_USER: " . (getenv('DB_USER') ?: ($_ENV['DB_USER'] ?? 'NOT SET')) . "\n";
echo "DB_PASS: " . (getenv('DB_PASS') ? '***SET***' : 'NOT SET') . "\n";
echo "APP_DEBUG: " . (getenv('APP_DEBUG') ?: ($_ENV['APP_DEBUG'] ?? 'NOT SET')) . "\n";
echo ".env exists: " . (file_exists(BASE_PATH . '/.env') ? 'YES' : 'NO') . "\n";
echo "PHP version: " . PHP_VERSION . "\n";
echo "Extensions: " . implode(', ', get_loaded_extensions()) . "\n";
echo '</pre>';
echo '</body></html>';
} else {
http_response_code(500);
header('Content-Type: text/html; charset=utf-8');
echo '<html dir="rtl"><body style="font-family:Cairo,sans-serif;text-align:center;padding:100px;background:#f9fafb;">';
echo '<h1 style="color:#dc2626;">حدث خطأ في النظام</h1>';
echo '<p style="color:#6b7280;">يرجى التواصل مع مسئول النظام</p>';
echo '</body></html>';
}
exit(1);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment