Migrating to express.js project

This commit is contained in:
2022-11-01 22:00:38 -04:00
parent e5c7bdedc1
commit 53e0a557a3
14 changed files with 1045 additions and 1551 deletions

View File

@ -1,19 +0,0 @@
<?php
namespace BitGoblin\Overseer\Controllers;
use Psr\Container\ContainerInterface;
class Controller {
protected $container;
public function __construct(ContainerInterface $container) {
$this->container = $container;
}
public function get(string $name) {
return $this->container->get($name);
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace BitGoblin\Overseer\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;
class HomeController extends Controller {
public function getIndex(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'index.twig');
}
}

View File

@ -1,25 +0,0 @@
<?php
use DI\Container;
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigMiddleware;
require __DIR__ . '/../vendor/autoload.php';
// Create new container object and add our config object to it
$container = new Container();
// Set container to create App with on AppFactory
AppFactory::setContainer($container);
$app = AppFactory::create();
// create Twig instance
$twig = Twig::create('views', ['cache' => false]);
// add Twig-View Middleware
$app->add(TwigMiddleware::create($app, $twig));
// load routes
require_once __DIR__ . '/routes.php';
// app starts in public/index.php

View File

@ -1,7 +0,0 @@
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
// index GET route - this page should welcome the user and direct them to the available actions
$app->get('/', '\\BitGoblin\\Overseer\\Controllers\\HomeController:getIndex')->setName('index');