mcst/src/app.php

36 lines
880 B
PHP
Raw Normal View History

<?php
2022-09-22 22:17:41 -04:00
use DI\Container;
use Noodlehaus\Config;
use Noodlehaus\Parser\Json;
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigMiddleware;
require __DIR__ . '/../vendor/autoload.php';
2022-09-22 22:17:41 -04:00
// Load app configuration
$config = Config::load(__DIR__ . '/../conf/defaults.json');
// Create new container object and add our config object to it
$container = new Container();
$container->set('config', function() use ($config) {
return $config;
});
// Set container to create App with on AppFactory
AppFactory::setContainer($container);
$app = AppFactory::create();
// Add Error Handling Middleware
$app->addErrorMiddleware(true, false, false);
// Create Twig
$twig = Twig::create(__DIR__ . '/../views', ['cache' => false]);
// Add Twig-View Middleware
$app->add(TwigMiddleware::create($app, $twig));
2022-09-22 22:17:41 -04:00
// load in route handlers
require_once __DIR__ . '/routes.php';