<?php

use Illuminate\Foundation\Application;
use Illuminate\Http\Request;

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

// cPanel / shared-hosting hardening:
// Some hosts restrict the system temp dir via open_basedir; Blade compilation uses tempnam().
// Force temp files into a writable dir inside storage/.
$tmp = __DIR__ . '/../storage/framework/tmp';
if (! is_dir($tmp)) {
    @mkdir($tmp, 0775, true);
}
@ini_set('sys_temp_dir', $tmp);

// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
    require $maintenance;
}

// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';

// Bootstrap Laravel and handle the request...
/** @var Application $app */
$app = require_once __DIR__.'/../bootstrap/app.php';

$app->handleRequest(Request::capture());
