$app->configureMode('production', function () use($app) { $app->config(array('log.enable' => true, 'log.level' => \Slim\Log::WARN, 'debug' => false)); }); // Only invoked if mode is "development" $app->configureMode('development', function () use($app) { $app->config(array('log.enable' => true, 'log.level' => \Slim\Log::DEBUG, 'debug' => false)); }); // Get log writer $log = $app->getLog(); // Init database try { if (!empty($config['db'])) { \ORM::configure($config['db']['dsn']); if (!empty($config['db']['username']) && !empty($config['db']['password'])) { \ORM::configure('username', $config['db']['username']); \ORM::configure('password', $config['db']['password']); } } } catch (\PDOException $e) { $log->error($e->getMessage()); } // Cache Middleware (inner) $app->add(new API\Middleware\Cache('/api/v1')); // Parses JSON body $app->add(new \Slim\Middleware\ContentTypes()); // Manage Rate Limit $app->add(new API\Middleware\RateLimit('/api/v1')); // JSON Middleware $app->add(new API\Middleware\JSON('/api/v1')); // Auth Middleware (outer) $app->add(new API\Middleware\TokenOverBasicAuth(array('root' => '/api/v1')));
} } \ORM::configure('logging', true); \ORM::configure('logger', function ($log_string, $query_time) use($log) { $log->debug($log_string . '-' . $query_time); }); \ORM::configure('error_mode', \PDO::ERRMODE_WARNING); } catch (\PDOException $e) { $log->error($e->getMessage()); } $app = new Application($config['app']); #$app->validaEmail(['email'=>'ffjff@jhjhg']); // Cache Middleware (inner) #$app->add(new API\Middleware\Cache('/api/v1')); // Parses JSON body $app->add(new \Slim\Middleware\ContentTypes()); #$app->add(new \Slim\Middleware\Navigation('/api/v1',$auth)); #$app->add(new \Slim\Middleware\Navigation('/api/v1',$auth)); // Manage Rate Limit #$app->add(new API\Middleware\RateLimit('/api/v1')); // JSON Middleware #$app->add(new API\Middleware\JSON('/api/v1')); // Auth Middleware (outer) #$app->add(new API\Middleware\TokenOverBasicAuth(array('root' => '/api/v1'))); ################################################################### ################################################################### /* */ /* $app->hook('slim.before.dispatch', function () use ($app) { $app->render('../../assets/templates/header.php');