예제 #1
0
<?php

require '../vendor/autoload.php';
include '../config.php';
include '../db.php';
define('APP_PATH', realpath(dirname(__DIR__)));
define('SITE_ROOT', $site_root);
checkAndInitDatabase(APP_PATH . "/database.sqlite");
$app = new \Slim\Slim(array('view' => new \Slim\Views\Twig()));
$app->config('debug', true);
$app->config('templates.path', '../templates');
$app->setName('SiteMigrator');
$app->container->singleton('db', function () {
    return new PDO("sqlite:" . APP_PATH . "/database.sqlite");
});
$view = $app->view();
$view->parserOptions = array('debug' => true, 'cache' => false);
$view->parserExtensions = array(new \Slim\Views\TwigExtension());
$app->get('/', function () use($app) {
    $app->render('index.html', array('title' => 'Home', 'site_root' => SITE_ROOT));
});
$app->get('/dns', function () use($app) {
    $sql = $app->db;
    $app->render('dns.html', array('title' => 'DNS', 'site_root' => SITE_ROOT));
});
$app->get('/emails', function () use($app) {
    $app->render('emails.html', array('title' => 'Emails', 'site_root' => SITE_ROOT));
});
$app->get('/databases', function () use($app) {
    $app->render('databases.html', array('title' => 'Databases', 'site_root' => SITE_ROOT));
});
예제 #2
0
파일: index.php 프로젝트: greboid/Holidays
use greboid\holidays\Acl;
use greboid\holidays\Periods;
use greboid\holidays\Allowances;
use greboid\holidays\DebugAdapter;
use Slim\Slim;
use Slim\Views\Twig;
use Slim\Views\TwigExtension;
define('APP_PATH', realpath(dirname(__DIR__)));
$roles = array('admin', 'employee', 'guest');
$app = new Slim(array('view' => new Twig()));
$app->config('debug', false);
$app->config('templates.path', '../templates');
$app->setName('Holidays');
$app->container->singleton('db', function () {
    $database = new PDO("sqlite:" . APP_PATH . "../databases/database.sqlite");
    checkAndInitDatabase($database);
    return $database;
});
$app->container->singleton('periods', function () use($app) {
    return new Periods($app->db);
});
$app->container->singleton('allowances', function () use($app) {
    return new Allowances($app->db);
});
$view = $app->view();
$app->configureMode('production', function () use($app, $view) {
    (new Bootstrap($app, new PdoAdapter($app->db, 'users', 'user', 'hash', new PasswordValidator()), new acl()))->bootstrap();
    $app->config(array('log.enable' => true, 'templates.path' => '../templates', 'debug' => false));
    $view->parserOptions = array('debug' => false, 'cache' => dirname(__FILE__) . '/../cache', 'auto_reload' => true);
    $view->parserExtensions = array(new TwigExtension());
});