<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Detect Application Root
|--------------------------------------------------------------------------
| Dev (XAMPP): project root is one level above public/
| Live (cPanel): project folder "ecommerce" sits beside public_html/
|--------------------------------------------------------------------------
*/
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
// Local / dev — standard Laravel structure
define('APP_ROOT', realpath(__DIR__ . '/..'));
} elseif (file_exists(__DIR__ . '/../ecommerce/vendor/autoload.php')) {
// cPanel — ecommerce/ folder is beside public_html/
define('APP_ROOT', realpath(__DIR__ . '/../ecommerce'));
} else {
http_response_code(503);
die('<h2>Application Error</h2><p>Laravel root not found. Please check installation.</p>');
}
/*
|--------------------------------------------------------------------------
| Maintenance Mode
|--------------------------------------------------------------------------
*/
if (file_exists($maintenance = APP_ROOT . '/storage/framework/maintenance.php')) {
require $maintenance;
}
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
*/
require APP_ROOT . '/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
*/
$app = require_once APP_ROOT . '/bootstrap/app.php';
$kernel = $app->make(Kernel::class);
$response = $kernel->handle(
$request = Request::capture()
)->send();
$kernel->terminate($request, $response);