Exemplo n.º 1
0
error_reporting(E_ALL);
//__connection à la base de données
$dsn = 'mysql:host=localhost;dbname=base;charset=utf8';
$usr = '******';
$pwd = 'admin';
//__ initialisation des variables
$app = new Slim\App(array('log.writer' => new \Slim\Logger\DateTimeFileWriter()));
$pdo = new \Slim\PDO\Database($dsn, $usr, $pwd);
$helper = new Helpers();
// Fetch DI Container
$container = $app->getContainer();
// Register Twig View helper
$container['view'] = function ($c) {
    $view = new \Slim\Views\Twig('views');
    /*
    $view = new \Slim\Views\Twig('views', [
        'cache' => 'cache'
    ]);
    */
    // Instantiate and add Slim specific extension
    $view->addExtension(new Slim\Views\TwigExtension($c['router'], $c['request']->getUri()));
    return $view;
};
//__ Algorithme
$helper->slash();
//__ routing : Automatically load router files
$routers = glob('routers/*.router.php');
foreach ($routers as $router) {
    require $router;
}
$app->run();