Created
May 31, 2022 02:22
-
-
Save buchin/f0e9a9fe109036c7d6cefffb5e3906c7 to your computer and use it in GitHub Desktop.
Shuriken Native Index.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Illuminate/Routing | |
* | |
* @source https://github.com/illuminate/routing | |
* @contributor Muhammed Gufran | |
* @contributor Matt Stauffer | |
* @contributor https://github.com/jwalton512 | |
* @contributor https://github.com/dead23angel | |
*/ | |
require_once "vendor/autoload.php"; | |
use Illuminate\Container\Container; | |
use Illuminate\Events\Dispatcher; | |
use Illuminate\Http\Request; | |
use Illuminate\Routing\Redirector; | |
use Illuminate\Routing\Router; | |
use Illuminate\Database\Capsule\Manager as Capsule; | |
use Illuminate\Config\Repository; | |
use Jenssegers\Blade\Blade; | |
use Illuminate\Routing\UrlGenerator; | |
include "functions.php"; | |
prepare_database(); | |
$capsule = new Capsule(); | |
$capsule->addConnection([ | |
"driver" => "sqlite", | |
"database" => prepare_database(), | |
"prefix" => "", | |
]); | |
$capsule->setEventDispatcher(new Dispatcher(new Container())); | |
$capsule->setAsGlobal(); | |
$capsule->bootEloquent(); | |
// Create a service container | |
$container = new Container(); | |
// Create a request from server variables, and bind it to the container; optional | |
$request = Request::capture(); | |
$container->instance("Illuminate\Http\Request", $request); | |
// Using Illuminate/Events/Dispatcher here (not required); any implementation of | |
// Illuminate/Contracts/Event/Dispatcher is acceptable | |
$events = new Dispatcher($container); | |
// Create the router instance | |
$router = new Router($events, $container); | |
// Load the routes | |
require_once "routes.php"; | |
// Create the redirect instance | |
$redirect = new Redirector(new UrlGenerator($router->getRoutes(), $request)); | |
// use redirect | |
// return $redirect->home(); | |
// return $redirect->back(); | |
// return $redirect->to('/'); | |
// Dispatch the request through the router | |
$response = $router->dispatch($request); | |
if (str_contains($request->getRequestUri(), "sitemap.xml")) { | |
$response->headers->set("Content-Type", "text/xml"); | |
} | |
// Send the response back to the browser | |
$response->send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment