Skip to content

Instantly share code, notes, and snippets.

@malgorath
Created December 10, 2014 20:00
Show Gist options
  • Save malgorath/88154fa039e288809891 to your computer and use it in GitHub Desktop.
Save malgorath/88154fa039e288809891 to your computer and use it in GitHub Desktop.
/public/index.php
<?php
require '../vendor/autoload.php';
require '../config.php';
session_start();
# initialize $app to contain slim framework
$app = new \Slim\Slim();
# setup configurations for $app
$app->config('debug', true);
$app->config('mode', 'development');
$app->container->singleton('twig', function ($c) {
$twig = new \Slim\Views\Twig();
$twig->parserOptions = array(
'debug' => true,
'cache' => '../cache'
);
$twig->parserExtensions = array(
new \Slim\Views\TwigExtension(),
new \Twig_Extension_Debug(),
);
$templatesPath = '../templates/';
$twig->setTemplatesDirectory($templatesPath);
return $twig;
});
$app->twig->getEnvironment()->addGlobal("session", $_SESSION);
# include all route files
$routers = glob('../routers/*.router.php');
foreach ($routers as $router) {
require $router;
}
$app->session = $_SESSION;
# Run application website
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment