2022-03-19 00:00:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace brain\init;
|
|
|
|
|
2022-04-14 23:46:17 +02:00
|
|
|
use brain\utility\HandleCors;
|
2022-03-19 00:00:51 +01:00
|
|
|
use Slim\Factory\AppFactory;
|
|
|
|
use Slim\Views\Twig;
|
2022-04-14 23:46:17 +02:00
|
|
|
use Slim\Views\TwigMiddleware;
|
2022-03-19 00:00:51 +01:00
|
|
|
|
|
|
|
class App
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
// when a new class is made, run composer dump-autoload
|
|
|
|
// set up cors
|
|
|
|
new HandleCors();
|
2022-05-17 02:41:15 +02:00
|
|
|
$app = AppFactory::create();
|
2022-04-14 23:46:17 +02:00
|
|
|
$twig = Twig::create('../brain/views/');
|
2022-03-19 00:00:51 +01:00
|
|
|
$app->add(TwigMiddleware::create($app, $twig));
|
2022-04-14 23:46:17 +02:00
|
|
|
// set up routing
|
2022-03-19 00:00:51 +01:00
|
|
|
$app->get(
|
2022-04-14 23:46:17 +02:00
|
|
|
'/[{first}[/{second}[/{third}[/{fourth}[/{fifth}]]]]]',
|
2022-03-19 00:00:51 +01:00
|
|
|
"brain\controller\RouteControl:get"
|
|
|
|
);
|
|
|
|
$app->post(
|
2022-04-14 23:46:17 +02:00
|
|
|
'/[{first}[/{second}[/{third}[/{fourth}]]]]',
|
2022-03-19 00:00:51 +01:00
|
|
|
"brain\controller\RouteControl:post"
|
|
|
|
);
|
2022-04-14 23:46:17 +02:00
|
|
|
// start the app
|
2022-03-19 00:00:51 +01:00
|
|
|
|
|
|
|
$app->run();
|
|
|
|
}
|
|
|
|
}
|