Ejemplo n.º 1
0
 public static function run()
 {
     //初始化session
     session_start();
     //初始化配置文件
     Config::getInstance();
     $appConfig = Config::get('app');
     //初始化主题
     $public = $appConfig['public'] ? $appConfig['public'] : 'public';
     Filesystem::mkdir($public, 444);
     if (!empty($appConfig['theme'])) {
         defined("APP_THEME") or define("APP_THEME", $public . '/' . $appConfig['theme']);
     } else {
         defined("APP_THEME") or define("APP_THEME", $public);
     }
     //初始化应用名字
     if (!empty($appConfig['name'])) {
         defined("APP_NAME") or define("APP_NAME", $appConfig['name']);
     } else {
         defined("APP_NAME") or define("APP_NAME", 'Simpla');
     }
     //初始化应用URL域名
     defined("BASE_URL") or define("BASE_URL", $appConfig['url']);
     //是否开启错误提示
     if ($appConfig['debug'] == 1) {
         error_reporting(E_ALL);
     } else {
         error_reporting(0);
     }
     //初始化数据库
     Model::getInstance();
     //初始化缓存
     ICache::getInstance();
     Cache::getInstance();
     //初始化whoops
     $run = new \Whoops\Run();
     $handler = new PrettyPageHandler();
     // 设置错误页面的标题
     $handler->setPageTitle("Whoops! 出现了一个错误.");
     $run->pushHandler($handler);
     //设置ajax错误提示.
     if (\Whoops\Util\Misc::isAjaxRequest()) {
         $run->pushHandler(new JsonResponseHandler());
     }
     // 注册handler
     $run->register();
     //路由处理
     Route::check();
 }
Ejemplo n.º 2
0
 /**
  * 缓存实例
  */
 public function actionCache()
 {
     $key = "product_page";
     //$InstanceCache = new Cache();
     $CachedString = Cache::get($key);
     if (is_null($CachedString)) {
         $CachedString = "Files Cache --> Well done !";
         // Write products to Cache in 10 minutes with same keyword
         Cache::set($key, $CachedString, 600);
         echo "FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // ";
         echo $CachedString;
     } else {
         echo "READ FROM CACHE // ";
         echo $CachedString;
     }
     echo '<br /><br /><a href="/">Back to index</a>';
 }