<?php

require __DIR__ . '/../vendor/autoload.php';
$app = require_once __DIR__ . '/../bootstrap/app.php';

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

// Boot the app
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();

// Login user with id 1
$user = App\Models\User::find(1);
if ($user) {
    Illuminate\Support\Facades\Auth::login($user);
}

$request = Illuminate\Http\Request::create('/admin', 'GET');

try {
    $response = $kernel->handle($request);
    echo "Status: " . $response->getStatusCode() . "\n";
    echo $response->getContent();
} catch (Throwable $e) {
    echo "Exception: " . get_class($e) . "\n";
    echo $e->getMessage() . "\n";
    echo $e->getTraceAsString() . "\n";
}
