website/app/start.php

71 lines
1.4 KiB
PHP
Raw Normal View History

2015-08-30 12:34:43 -04:00
<?php
// Slim deps
use Slim\Slim;
use Slim\Views\Twig;
use Slim\Views\TwigExtension;
// Config struff
use Noodlehaus\Config;
// Our dependencies
//use Fieldprotocol\User\User;
// Let's get this session started
session_cache_limiter(false);
session_start();
// For now, display some errors
ini_set('display_errors', 'On');
// The app's root directory
define('INC_ROOT', dirname(__DIR__));
// Autoload our stuff >:D
require INC_ROOT . '/vendor/autoload.php';
// Time to create our app
$app = new Slim([
'mode' => file_get_contents(INC_ROOT . '/mode.php'),
'view' => new Twig(),
'templates.path' => INC_ROOT . '/app/views'
]);
// Run some crap before the middleware
//$app->add(new BeforeMiddleware);
//$app->add(new CSRFMiddleware);
$app->configureMode($app->config('mode'), function() use ($app) {
$app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php");
});
// Database configs
require 'database.php';
// Filters
require 'filters.php';
// Routes configs
require 'routes.php';
//$app-auth = false;
$app->container->set('user', function() {
return new User;
});
$app->container->set('post', function() {
return new Post;
});
// Slappin' some hoes with our views
$view = $app->view();
$view->parserOptions = [
'debug' => $app->config->get('twig.debug')
];
$view->setTemplatesDirectory('../app/views');
$view->parserExtensions = [
new TwigExtension()
];
// Run Slim
$app->run();