/** * 文件缓存 * * @param array $config 配置参数 * @return \phpFastCache\Core\DriverAbstract */ private function file($config = array()) { $filePath = $config['filePath']; if (!file_exists($filePath)) { Filesystem::mkdir($filePath); } //初始化缓存路径 CacheManager::setup(array("path" => isset($filePath) ? $filePath : sys_get_temp_dir())); CacheManager::CachingMethod("phpfastcache"); //初始化缓存 $InstanceCache = CacheManager::Files(); return $InstanceCache; }
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(); }
/** * 获取视图所在文件夹 * @return string */ public static function getViewPath($type = 'base') { if ($type == 'base') { $appConfig = Config::get('app'); if (empty($appConfig['theme'])) { $viewPath = APP_PATH . '/views'; } else { $viewPath = APP_PATH . '/views/' . $appConfig['theme']; } } elseif ($type == 'module') { $module = RouteHandle::getModuleName(); $viewPath = APP_PATH . '/Modules/' . $module . '/views/'; } //进行view地址进行校验,不存在则生成,防止plates报错 if (!file_exists($viewPath)) { Filesystem::mkdir($viewPath); } return $viewPath; }