load(); //production settings $mode = getenv('APP_ENV'); $debug = false; //localhost settings if ($mode === 'development') { if (getenv('WHOOPS')) { //pretty error page $whoops = new \Whoops\Run; $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler); $whoops->register(); } $debug = true; $domain = 'havais.dev'; } else { //Tüm subdomain ve site için session $domain = 'havais.org.tr'; } /////////////////////////////// //////// Pre - Configs ///////////// require_once SITE_PATH . '/config/log.php'; //Loglama /////////////////////////////// /////////////////////////////// //region SLIM //////// Slim Init //////////// $app = new Slim(array( 'mode' => $mode, 'debug' => $debug, 'view' => new Twig(), 'log.enabled' => true, //log aktif 'log.writer' => $logger, //Log yazıcısı monolog 'log.level' => Log::WARN, 'cookies.path' => '/', 'cookies.domain' => $domain, //domain ayarı 'cookies.lifetime' => '2 weeks', // 2 hafta ömrü var 'cookies.httponly' => true, //sadece server side eriş 'cookies.encrypt' => true,// cookies değerini hashledik 'cookies.secret_key' => 'e2b7ad826e0551ccc3a4a1b0b583404a0587e2e9', //secret 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.cipher_mode' => MCRYPT_MODE_CBC )); $app->add(new ContentTypes()); $app->add(new PrettyExceptions()); if ($mode !== 'development') { $app->add(new Minify()); $app->notFound(function () use ($app) { $app->redirect('/'); }); } //////// Twig extensions Init ////////////https://github.com/codeguy/Slim-Views $view = $app->view(); $view->parserOptions = array( 'debug' => true, /*'auto_reload' => true, 'cache' => SITE_PATH . '/cache'*/ ); $view->parserExtensions = array(new TwigExtension(),new Twig_Extension_Debug() ); $view->setTemplatesDirectory(SITE_PATH . '/templates'); $twig = $app->view->getEnvironment(); /////////////////////////////// //endregion //////// App Based Configs ///////////// require_once SITE_PATH . '/config/app.php'; //Tüm site bilgilerini tutat require_once SITE_PATH . '/config/db.php'; //DB bilgilerini tutar require_once SITE_PATH . '/helpers/constants.php'; //Crud Typelar için yardımcı require_once SITE_PATH . '/helpers/common.php'; //Yardımcı fonksiyonlar require_once SITE_PATH . '/helpers/ReCaptcha.php'; //ReCaptcha require_once SITE_PATH . '/models/models.php'; //models holder ///////////////////////////////// //////// Helpers //////////////// require_once SITE_PATH . '/helpers/controllers.php'; //controller holder require_once SITE_PATH . '/helpers/filters.php'; //filters holder require_once SITE_PATH . '/helpers/tools.php'; //tools holder require_once SITE_PATH . '/helpers/lang.php'; //Holds language info require_once SITE_PATH . '/config/lang-redirect.php'; ///////////////////////////////// ////////// DI kısmı ////////////// $app->self = $app; $app->twig = $twig; //Twig global $app->logger = $logger;//loglama ////////// Lang //////////////// //Get current lang Lang::detect_lang($app); require_once SITE_PATH . '/lang/' . Lang::$current . '.php'; $app->lang = $lang; //////////////////////////////// //start session session_start(); //////// Routes //////////////// require_once SITE_PATH . '/routes/admin/routes.php'; //Admin panel routeları require_once SITE_PATH . '/routes/site/routes.php'; //Site routeları //-- RUN! $app->run();