<?php

/**
 * Sabzimart - Production Entry Point (Shared Hosting)
 *
 * This file is the entry point for shared hosting environments where
 * the public_html directory is separate from the Laravel core.
 *
 * Directory Structure:
 *   /home/user/laravel_core/   <-- Laravel application files
 *   /home/user/public_html/    <-- This file + public assets
 */

use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenanc
|--------------------------------------------------------------------------
*/

if (file_exists($maintenance = __DIR__ . '/../laravel_core/storage/framework/maintenance.php')) {
    require $maintenance;
}

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
*/

require __DIR__ . '/../laravel_core/vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
*/

$app = require_once __DIR__ . '/../laravel_core/bootstrap/app.php';

// Override the public path for shared hosting
$app->bind('path.public', function () {
    return __DIR__;
});

$kernel = $app->make(Kernel::class);

$response = $kernel->handle(
    $request = Request::capture()
)->send();

$kernel->terminate($request, $response);
