website/app/start.php

74 lines
1.5 KiB
PHP
Raw Permalink 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
2016-04-20 21:53:00 -04:00
use Fieldprotocol\Music\Album;
2016-04-20 23:39:44 -04:00
use Fieldprotocol\Music\Song;
2015-08-30 12:34:43 -04:00
// 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' => trim(file_get_contents(INC_ROOT . '/mode.php')),
2015-08-30 12:34:43 -04:00
'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';
2015-09-29 17:10:16 -04:00
//$app->auth = false;
2015-08-30 12:34:43 -04:00
2016-04-20 21:53:00 -04:00
// Album singleton
$app->container->set('album', function() {
return new Album;
2016-04-20 23:39:44 -04:00
});
2015-08-30 12:34:43 -04:00
2016-04-20 21:53:00 -04:00
// Song singleton
$app->container->set('song', function() {
return new Song;
2015-08-30 12:34:43 -04:00
});
// 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();