grthtrhthjhtyjytjytkergtrhtrjytjerhrfh<?php

/**
 * cPanel public_html/index.php
 *
 * This is a MODIFIED entry point for shared cPanel hosting.
 * It lives in public_html/ but routes all traffic to the Laravel app
 * located at /home/USERNAME/ali-composers/ (above public_html).
 *
 * Setup:
 *   1. Upload your entire Laravel project to /home/USERNAME/ali-composers/
 *      (NOT inside public_html — it must be in your home directory)
 *   2. Copy this file to /home/USERNAME/public_html/index.php
 *   3. Copy cpanel/htaccess-public to /home/USERNAME/public_html/.htaccess
 *   4. Edit the ALI_APP_BASE path below if your project lives elsewhere
 *   5. Make sure storage/ and bootstrap/cache/ are writable (chmod 775)
 *
 * Security: this approach keeps your .env, app/, config/ etc. OUTSIDE
 * the web root, so they can never be downloaded via browser.
 */

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

// ─── EDIT THIS IF YOUR LARAVEL PROJECT IS IN A DIFFERENT FOLDER ───────
// Default: /home/USERNAME/ali-composers/
// The script auto-detects your cPanel home directory.
$ALI_APP_BASE = dirname(__DIR__) . '/ali-composers';

// Fallback: if the path above doesn't exist, look in common locations
if (! is_dir($ALI_APP_BASE)) {
    $candidates = [
        dirname(__DIR__) . '/ali-composers',
        dirname(__DIR__) . '/laravel-backend',
        dirname(__DIR__) . '/app',
        dirname(__DIR__) . '/api',
    ];
    foreach ($candidates as $c) {
        if (is_dir($c) && file_exists($c . '/bootstrap/app.php')) {
            $ALI_APP_BASE = $c;
            break;
        }
    }
}

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

// Laravel's autoloader
$autoloadPath = $ALI_APP_BASE . '/vendor/autoload.php';
if (! file_exists($autoloadPath)) {
    http_response_code(500);
    exit("Laravel vendor/autoload.php not found at: {$autoloadPath}. Run 'composer install' first.");
}
require $autoloadPath;

// Bootstrap Laravel
$appPath = $ALI_APP_BASE . '/bootstrap/app.php';
if (! file_exists($appPath)) {
    http_response_code(500);
    exit("Laravel bootstrap/app.php not found at: {$appPath}");
}
$app = require_once $appPath;

// Laravel needs to know where the real public/ directory is (for assets)
// We point it back to the public_html directory since that's where Apache serves from.
$app->instance('path.public', __DIR__);

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

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

$ke