예제 #1
0
파일: web.class.php 프로젝트: roc/Borax
 public function handleRequest()
 {
     // Encapsulate an HTTP request
     $request = new Request();
     // Don't show HTML errors for JSON
     if ($request->acceptJson()) {
         ini_set('html_errors', 0);
     }
     // Encapsulate the user session
     if (class_exists('App\\Session')) {
         $session = new App\Session($request);
     } else {
         $session = new Session($request);
     }
     $request->setSession($session);
     // Setup the dispatcher with App URL patterns
     $routes = self::getPatterns();
     if (class_exists('App\\Route')) {
         $routes = array_merge(App\Route::getPatterns($request), $routes);
     }
     $dispatcher = new Dispatcher($request, $routes);
     // Process the request
     $response = $dispatcher->processRequest($request);
     $response->setHeaders($session->getHeaders());
     // Render the response
     $response->respond();
 }
예제 #2
0
파일: Eny.php 프로젝트: sinfey69/enyphp
 /**
  * 初始化
  * @return void
  */
 public static function boot()
 {
     // 目录定义
     self::structure();
     // 初始化环境
     self::environment();
     // 加载配置
     Config::configure(CONFIG);
     // 数据检查
     Validate::validity();
     // session初始化
     Session::start();
     // 调度程序
     Dispatcher::dispatch();
 }
예제 #3
0
 private static function init()
 {
     // 加载应用公共文件和配置
     // C(include CONF_PATH . 'config' .CONF_EXT);
     // 定义当前请求的系统常量
     define('NOW_TIME', $_SERVER['REQUEST_TIME']);
     define('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
     define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
     define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
     define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
     define('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
     define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ? true : false);
     // URL调度
     \Core\Dispatcher::run();
     // URL调度结束标签
     Hook::listen('url_dispatch');
     //没有对应的行为函数,返回null notes by lwh 2015-11-19
     return;
 }