36 lines
880 B
PHP
36 lines
880 B
PHP
<?php
|
|
|
|
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';
|
|
|
|
// 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));
|
|
|
|
// load in route handlers
|
|
require_once __DIR__ . '/routes.php';
|