From 13be13f0679f21451ba49db677e246ded5bd6cd8 Mon Sep 17 00:00:00 2001 From: Puleeno Nguyen Date: Sun, 21 Apr 2024 10:21:42 +0700 Subject: [PATCH] prepare to support Laravel structure --- app/Console/Application.php | 9 ------ app/Console/Kernel.php | 7 +++++ app/Exceptions/Handler.php | 9 ++++++ app/Http/Kernel.php | 58 ++----------------------------------- app/bootstrap.php | 4 +-- bootstrap/app.php | 19 ++++++++++++ extensions/dashboard | 2 +- extensions/react | 2 +- public/index.php | 58 ++++++++++++++++++++++++++++++++++--- 9 files changed, 95 insertions(+), 73 deletions(-) delete mode 100644 app/Console/Application.php create mode 100644 app/Console/Kernel.php create mode 100644 app/Exceptions/Handler.php create mode 100644 bootstrap/app.php diff --git a/app/Console/Application.php b/app/Console/Application.php deleted file mode 100644 index c5b844b..0000000 --- a/app/Console/Application.php +++ /dev/null @@ -1,9 +0,0 @@ -app = $app; - } - - /** - * Configure the application. - */ - public function configure() - { - $this->app->booted(); - } - - - /** - * Call the terminate method on any terminable middleware. - * - * @param \Psr\Http\Message\RequestInterface $request - * @param \Psr\Http\Message\ResponseInterface $response - * @return void - */ - public function terminate(RequestInterface $request, ResponseInterface $response) - { - $this->terminateMiddleware($request, $response); - - $this->app->terminate(); - } - - - - /** - * Call the terminate method on any terminable middleware. - * - * @param \Psr\Http\Message\RequestInterface $request - * @param \Psr\Http\Message\ResponseInterface $response - * @return void - */ - protected function terminateMiddleware($request, $response) - { - // placeholder to terminal middlewares - } } diff --git a/app/bootstrap.php b/app/bootstrap.php index 15e1b71..9cd8da3 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -127,8 +127,8 @@ protected function setup() $this->app = AppFactory::createApp(); - $kernel = new Kernel($this->app); - $kernel->configure(); + // $kernel = new Kernel($this->app); + // $kernel->configure(); // Register middleware $middleware = $this->loadSetting('middleware'); diff --git a/bootstrap/app.php b/bootstrap/app.php new file mode 100644 index 0000000..2db75d6 --- /dev/null +++ b/bootstrap/app.php @@ -0,0 +1,19 @@ +singleton( + \Quagga\Quagga\Foundation\Http\Kernel::class, + \App\Http\Kernel::class +); + +$app->singleton( + \Quagga\Contracts\Debug\ExceptionHandler::class, + \App\Exceptions\Handler::class +); + + +return $app; + diff --git a/extensions/dashboard b/extensions/dashboard index 99c90c8..d9cb945 160000 --- a/extensions/dashboard +++ b/extensions/dashboard @@ -1 +1 @@ -Subproject commit 99c90c8c65f837f4c038863a9e14acdf852caa4d +Subproject commit d9cb945c4da574ed9445f4f99ba946208d95c051 diff --git a/extensions/react b/extensions/react index b2b0c78..b379ef1 160000 --- a/extensions/react +++ b/extensions/react @@ -1 +1 @@ -Subproject commit b2b0c78bb33d0908975a0c63958d8644e6f83070 +Subproject commit b379ef1d318f286ef75e1b4739f45fd1720f0663 diff --git a/public/index.php b/public/index.php index 23554b8..13dd57e 100644 --- a/public/index.php +++ b/public/index.php @@ -1,10 +1,60 @@ boot(); + +exit(); + +/* +|-------------------------------------------------------------------------- +| Register The Auto Loader +|-------------------------------------------------------------------------- +| +| Composer provides a convenient, automatically generated class loader for +| our application. We just need to utilize it! We'll simply require it +| into the script here so that we don't have to worry about manual +| loading any of our classes later on. It feels great to relax. +| +*/ + +require __DIR__.'/../vendor/autoload.php'; + +/* +|-------------------------------------------------------------------------- +| Turn On The Lights +|-------------------------------------------------------------------------- +| +| We need to illuminate PHP development, so let us turn on the lights. +| This bootstraps the framework and gets it ready for use, then it +| will load up this application so that we can run it and send +| the responses back to the browser and delight our users. +| +*/ + +$app = require_once __DIR__.'/../bootstrap/app.php'; + +/* +|-------------------------------------------------------------------------- +| Run The Application +|-------------------------------------------------------------------------- +| +| Once we have the application, we can handle the incoming request +| through the kernel, and send the associated response back to +| the client's browser allowing them to enjoy the creative +| and wonderful application we have prepared for them. +| +*/ + +$kernel = $app->make(\Quagga\Contracts\Http\Kernel::class); + +$response = $kernel->handle( + $request = \Quagga\Quagga\Http\Request::capture() +); + +$response->send(); + +$kernel->terminate($request, $response);