Exemple #1
0
<?php

use wuyuan\wy;
define('WY_DEBUG', TRUE);
define('WY_APP_DIR', strtr(__DIR__, '\\', '/') . '/app/');
require __DIR__ . '/framework/wy.class.php';
wy::run();
Exemple #2
0
 /**
  * 解析请求.
  * 
  * @access public
  * @return void
  */
 public static function parseRequest()
 {
     $configs = Config::get(__CLASS__);
     self::$_configs = array_merge(self::$_configs, $configs);
     unset($configs);
     // 是否为分组模式.
     $groupMode = self::$_configs['groupMode'] && self::$_configs['groupList'];
     self::$_isGroup = $groupMode && self::$_configs['defaultGroup'];
     // 设置应用路径别名.
     $alias = strtok(self::$_configs['controllerNs'], '\\');
     wy::addAlias('@' . $alias, WY_APP_DIR);
     // 根据不同的 urlMode 解析.
     switch (self::$_configs['urlMode']) {
         case self::MODE_NORMAL:
             // normal.
             self::parseNormal();
             break;
         case self::MODE_PATHINFO:
             // pathinfo.
             self::parsePathinfo();
             break;
         default:
             // 默认 pathinfo.
             self::parsePathinfo();
     }
     // 分组模式, 合并分组节点的配置项.
     if (self::$_isGroup) {
         Config::loadNode(self::$_groupName);
     }
 }
Exemple #3
0
            ob_start();
        }
        header('Content-type: text/html; charset=' . $configs['default_charset']);
        unset($configs);
        if (NULL !== self::$onBeforeParseRequest) {
            call_user_func(self::$onBeforeParseRequest);
        }
        Url::parseRequest();
        // 解析请求.
        if (NULL !== self::$onBeforeDispatch) {
            call_user_func(self::$onBeforeDispatch);
        }
        Url::dispatch();
        // 请求分发.
        ob_end_flush();
        flush();
    }
}
// 引用框架核心类.
require WY_DIR . 'base/Exception.class.php';
require WY_DIR . 'base/Interfaces.class.php';
set_error_handler(['\\wuyuan\\wy', 'errorHandler']);
set_exception_handler(['\\wuyuan\\wy', 'exceptionHandler']);
register_shutdown_function(['\\wuyuan\\wy', 'fatalHandler']);
spl_autoload_register(['\\wuyuan\\wy', 'autoload'], TRUE, TRUE);
// 框架类映射.
$classMaps = ['wuyuan\\base\\Config' => WY_DIR . 'base/Config.class.php', 'wuyuan\\base\\Controller' => WY_DIR . 'base/Controller.class.php', 'wuyuan\\base\\Log' => WY_DIR . 'base/Log.class.php', 'wuyuan\\base\\Model' => WY_DIR . 'base/Model.class.php', 'wuyuan\\base\\Request' => WY_DIR . 'base/Request.class.php', 'wuyuan\\base\\Url' => WY_DIR . 'base/Url.class.php', 'wuyuan\\base\\Validator' => WY_DIR . 'base/Validator.class.php', 'wuyuan\\base\\View' => WY_DIR . 'base/View.class.php', 'wuyuan\\cookie\\Cookie' => WY_DIR . 'cookie/Cookie.class.php', 'wuyuan\\db\\Db' => WY_DIR . 'db/Db.class.php', 'wuyuan\\db\\Connection' => WY_DIR . 'db/Connection.class.php', 'wuyuan\\db\\driver\\Mysqli' => WY_DIR . 'db/driver/Mysqli.class.php', 'wuyuan\\image\\Image' => WY_DIR . 'image/Image.class.php', 'wuyuan\\image\\driver\\Gd' => WY_DIR . 'image/driver/Gd.class.php', 'wuyuan\\image\\dirver\\Gif' => WY_DIR . 'image/driver/Gif.class.php', 'wuyuan\\download\\Download' => WY_DIR . 'download/Download.class.php', 'wuyuan\\page\\Page' => WY_DIR . 'page/Page.class.php', 'wuyuan\\session\\Session' => WY_DIR . 'session/Session.class.php', 'wuyuan\\upload\\Upload' => WY_DIR . 'upload/Upload.class.php', 'wuyuan\\util\\DirtyWordFilter' => WY_DIR . 'util/DirtyWordFilter.class.php', 'wuyuan\\util\\SocketHttp' => WY_DIR . 'util/SocketHttp.class.php', 'wuyuan\\vcode\\Vcode' => WY_DIR . 'vcode/Vcode.class.php', 'wuyuan\\cache\\Cache' => WY_DIR . 'cache/Cache.class.php', 'wuyuan\\cache\\driver\\File' => WY_DIR . 'cache/driver/File.class.php'];
wy::addClassMap($classMaps, NULL);
// 执行框架初始化.
wy::initialize();
Exemple #4
0
 /**
  * {@inheritDoc}
  * 
  * @see \wuyuan\base\ICacheDriver::flush()
  */
 public function flush()
 {
     if (empty($this->configs['cacheDir'])) {
         throw new CacheException('请指定缓存目录.');
     }
     try {
         \wuyuan\wy::removeAllFile($this->configs['cacheDir'], TRUE);
     } catch (\Exception $e) {
         throw new CacheException($e->getMessage());
     }
     return $this;
 }
Exemple #5
0
 /**
  * 清除模板编译文件.
  * $tplName 为 NULL, 清除全部模板编译文件; $tplName 格式参见 display 方法说明.
  *
  * @access public
  * @param string $tplName 模板名称, 默认 NULL.
  * @return boolean 清除成功返回 TRUE; 否则返回 FALSE.
  */
 public function cleanCompile($tplName = NULL)
 {
     if (NULL === $tplName) {
         return wy::removeAllFile($this->configs['compileDir'], TRUE);
     }
     return unlink($this->fetchViewPath($tplName)['compile']);
 }