예제 #1
0
 private function __construct()
 {
     $this->env = Env::getInstance();
     //初始化数据
     $this->queryData()->postData()->fileData()->parseReq();
     $this->isAjax = $this->isAjax();
     $this->isXhr = $this->isAjax;
 }
예제 #2
0
 public function __construct()
 {
     $this->env = Env::getInstance();
     $this->themethod = $this->env->method();
     $this->router = new Router();
     $this->_notfound = function () {
         echo '<h1>404 Not Found</h1>';
         $vitex = Vitex::getInstance();
         if ($vitex->getConfig('debug')) {
             //输出调试信息
             $url = $this->env->getPathinfo();
             $patterns = $this->router->getPattern();
             echo '<h2>Router Detail</h2>';
             echo '<strong>URL</strong>: ' . $url . '<br /><strong>Matcher:</strong>';
             echo '<ul>';
             foreach ($patterns as list($method, $matcher, $call, $pattern)) {
                 echo sprintf('<li><span>Method: %s </span> <span>Url: %s</span> <span style="width:500px">RegExp: %s</span></li>', $method, $pattern, $matcher);
             }
             echo '</ul>';
             echo '<style type="text/css">li span{display:inline-block;width:150px;}</style>';
         }
     };
 }
예제 #3
0
 public function __construct()
 {
     $this->env = Env::getInstance();
     $this->setRegexp(['digit' => '[0-9]+', 'alpha' => '[a-zA-Z]+', 'alphadigit' => '[0-9a-zA-Z]+', 'float' => '[0-9]+\\.{1}[0-9]+']);
 }
예제 #4
0
 private function __construct()
 {
     //注册加载 加载器
     require __DIR__ . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . "Loader.php";
     $this->loader = new Loader();
     $this->loader->addNamespace("\\Vitex", __DIR__);
     $this->loader->register();
     //init app
     $this->settings = $this->defaultSetting;
     //初始化各种变量
     $this->env = Core\Env::getInstance();
     $this->route = new Core\Route();
     //初始化 request response
     $this->req = Core\Request::getInstance();
     $this->res = Core\Response::getInstance();
     $this->res->url = function ($url, $params = []) {
         return $this->url($url, $params);
     };
     //view视图
     $this->view = null;
     //日志
     $this->log = new Log();
     //添加第一个中间件,他总是最后一个执行
     $this->using(new Middleware\MethodOverride());
     date_default_timezone_set('Asia/Shanghai');
 }