Beispiel #1
0
 /**
  * 验证二级域名是否设置
  * @return boolean|string
  */
 public static function checkSecondDomain()
 {
     $domain = self::getSecondDomain();
     $domainConfig = Config::get('app.domain');
     if (isset($domainConfig[$domain])) {
         return $domainConfig[$domain];
     }
     return false;
 }
Beispiel #2
0
 private function getConnectType()
 {
     $dbConfig = simplaConfig::get('database');
     //获取数据库连接类型
     $dbType = isset($dbConfig['default']) ? $dbConfig['default'] : 'mysql';
     //获取数据库对应类型的配置信息
     $sqlConfig = $dbConfig['connections'][$dbType];
     $configInfo = 'mysql://' . $sqlConfig['username'] . ':' . $sqlConfig['password'] . '@' . $sqlConfig['host'] . '/' . $sqlConfig['database'];
     return $configInfo;
 }
 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();
 }
Beispiel #4
0
 /**
  * 获取视图所在文件夹
  * @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;
 }
Beispiel #5
0
 public function __construct()
 {
     $cacheConfig = Config::get('cache');
     switch ($cacheConfig['fileSystem']) {
         case 'file':
             $cache = self::file($cacheConfig['file']);
             break;
         case 'memcache':
             $cache = self::memcache($cacheConfig['memcache']);
             break;
         case 'memcached':
             $cache = self::memcached($cacheConfig['memcached']);
             break;
         case 'redis':
             $cache = self::redis($cacheConfig['redis']);
             break;
         case 'apc':
             $cache = self::apc();
             break;
         default:
             $cache = self::file($cacheConfig['file']);
     }
     self::$cache = $cache;
 }