Skip to content

Commit

Permalink
prepare to support Laravel structure
Browse files Browse the repository at this point in the history
  • Loading branch information
puleeno committed Apr 21, 2024
1 parent a75027d commit 13be13f
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 73 deletions.
9 changes: 0 additions & 9 deletions app/Console/Application.php

This file was deleted.

7 changes: 7 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\Console;

class Kernal
{
}
9 changes: 9 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace App\Exceptions;

use Quagga\Quagga\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
}
58 changes: 2 additions & 56 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,8 @@

namespace App\Http;

use Quagga\Contracts\ApplicationConstract;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Slim\App;
use Quagga\Quagga\Foundation\Http\Kernel as HttpKernel;

class Kernel
class Kernel extends HttpKernel
{
/**
* @var \Quagga\Contracts\ApplicationConstract
*/
private $app;

/**
* Constructor.
*
* @param ApplicationConstract $app
*/
public function __construct(ApplicationConstract $app)
{
$this->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
}
}
4 changes: 2 additions & 2 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
19 changes: 19 additions & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

$app = new \Quagga\Quagga\Foundation\Application(
!empty($_ENV['APP_BASE_PATH']) ? $_ENV['APP_BASE_PATH'] : dirname(__DIR__)
);

$app->singleton(
\Quagga\Quagga\Foundation\Http\Kernel::class,
\App\Http\Kernel::class
);

$app->singleton(
\Quagga\Contracts\Debug\ExceptionHandler::class,
\App\Exceptions\Handler::class
);


return $app;

58 changes: 54 additions & 4 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
<?php

declare(strict_types=1);
define('PULEENO_CMS_START', microtime(true));

use Quagga\Bootstrap;
define('QUAGGA_CMS_START', microtime(true));

require __DIR__ . '/../app/bootstrap.php';
$bootstrap = Bootstrap::getInstance();
$bootstrap = \Quagga\Bootstrap::getInstance();
$bootstrap->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);

0 comments on commit 13be13f

Please sign in to comment.