/** * @brief 请求执行方法,是application执行的入口方法 */ public function execRequest() { echo IWeb::exeTime() . "<br><br><br>"; IUrl::beginUrl(); $this->controller = $this->createController(); IInterceptor::run("onCreateController", $this->controller); $this->controller->run(); IInterceptor::run("onFinishController"); }
/** * @brief 构造函数 * @param array or string $config 配置数组或者配置文件名称 */ public function __construct($config) { if (is_string($config)) { $config = (require $config); } if (is_array($config)) { $this->config = $config; } else { $this->config = array(); } //设为if true为了标注以后要再解决cli模式下的basePath if (!isset($_SERVER['DOCUMENT_ROOT'])) { if (isset($_SERVER['SCRIPT_FILENAME'])) { $_SERVER['DOCUMENT_ROOT'] = dirname($_SERVER['SCRIPT_FILENAME']); } elseif (isset($_SERVER['PATH_TRANSLATED'])) { $_SERVER['DOCUMENT_ROOT'] = dirname(rtrim($_SERVER['PATH_TRANSLATED'], "/\\")); } } if ($web = true) { $script_dir = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\'); if ($script_dir != "") { $script_dir .= "/"; } $basePath = rtrim($_SERVER['DOCUMENT_ROOT'], '/\\') . "/" . $script_dir; $this->config['basePath'] = $basePath; $this->setBasePath($basePath); } if (isset($config['charset'])) { $this->setCharset($config['charset']); } if (isset($config['classes'])) { IWeb::setClasses($config['classes']); } if (isset($config['timezone'])) { date_default_timezone_set($config['timezone']); } else { date_default_timezone_set($this->timezone); } $debugMode = isset($config['debug']) && $config['debug'] === true ? true : false; $this->setDebugMode($debugMode); $this->disableMagicQuotes(); if (!isset($config['upload'])) { $this->config['upload'] = 'upload'; } //开始向拦截器里注册类 if (isset($config['interceptor']) && is_array($config['interceptor'])) { IInterceptor::reg($config['interceptor']); register_shutdown_function(array('IInterceptor', "shutDown")); } }
/** * @brief 构造函数 * @param array or string $config 配置数组或者配置文件名称 */ public function __construct($config) { echo 'ccccccccccc<br>'; IWeb::setApplication($this); echo __CLASS__ . ':555555555555<br>'; if (is_string($config) && is_file($config)) { $config = (require $config); } $this->config = is_array($config) ? $config : array(); //产品实际根路径 if (isset($this->config['basePath']) && $this->config['basePath']) { $basePath = $this->config['basePath']; } else { if (isset($_SERVER['SCRIPT_FILENAME'])) { $basePath = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR; } else { //document_root 不存在 if (!isset($_SERVER['DOCUMENT_ROOT'])) { if (isset($_SERVER['PATH_TRANSLATED'])) { $_SERVER['DOCUMENT_ROOT'] = dirname($_SERVER['PATH_TRANSLATED']); } } $basePath = rtrim(rtrim($_SERVER['DOCUMENT_ROOT'], '\\/') . dirname($_SERVER['SCRIPT_NAME']), '\\/') . DIRECTORY_SEPARATOR; } } echo '项目跟路径:' . $basePath . '<br>'; $this->setBasePath($basePath); ini_set('upload_tmp_dir', $basePath . 'runtime' . DIRECTORY_SEPARATOR); ini_set('session.save_path', $basePath . 'backup' . DIRECTORY_SEPARATOR); date_default_timezone_set(isset($config['timezone']) ? $config['timezone'] : 'Asia/Shanghai'); // 设置自动加载目录 IWeb::setClasses(isset($config['classes']) ? $config['classes'] : 'classes.*'); echo '<br>自定义类入口:' . print_r(IWeb::$_classes) . '<br>'; $this->charset = isset($config['charset']) ? $config['charset'] : $this->charset; $this->language = isset($config['lang']) ? $config['lang'] : $this->language; // Debug模式开关 $this->setDebugMode(isset($config['debug']) && $config['debug'] === true ? true : false); // POST,GET,REQUEST,COOKIE 自动过滤 $this->disableMagicQuotes(); // 开始向拦截器里注册类 if (isset($config['interceptor']) && is_array($config['interceptor'])) { IInterceptor::reg($config['interceptor']); register_shutdown_function(array('IInterceptor', "shutDown")); } }
/** * @brief 构造函数 * @param array or string $config 配置数组或者配置文件名称 */ public function __construct($config) { IWeb::setApplication($this); if (is_file($config)) { $config = (require $config); } $this->config = is_array($config) ? $config : array(); //设为if true为了标注以后要再解决cli模式下的basePath;产品实际根路径 if (isset($_SERVER['SCRIPT_FILENAME'])) { $basePath = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR; } else { //document_root 不存在 if (!isset($_SERVER['DOCUMENT_ROOT'])) { if (isset($_SERVER['PATH_TRANSLATED'])) { $_SERVER['DOCUMENT_ROOT'] = dirname($_SERVER['PATH_TRANSLATED']); } } $basePath = rtrim(rtrim($_SERVER['DOCUMENT_ROOT'], '\\/') . dirname($_SERVER['SCRIPT_NAME']), '\\/') . DIRECTORY_SEPARATOR; } //echo $basePath; $this->setBasePath($basePath); ini_set('upload_tmp_dir', $basePath . 'runtime' . DIRECTORY_SEPARATOR); //echo $basePath.'runtime'.DIRECTORY_SEPARATOR; ini_set('session.save_path', $basePath . 'backup' . DIRECTORY_SEPARATOR); date_default_timezone_set(isset($config['timezone']) ? $config['timezone'] : 'Asia/Shanghai'); IWeb::setClasses(isset($config['classes']) ? $config['classes'] : 'classes.*'); $this->charset = isset($config['charset']) ? $config['charset'] : $this->charset; $this->language = isset($config['lang']) ? $config['lang'] : $this->language; $this->setDebugMode(isset($config['debug']) && $config['debug'] === true ? true : false); //删除魔法转义 $this->disableMagicQuotes(); //开始向拦截器里注册类 //print_r($config); if (isset($config['interceptor']) && is_array($config['interceptor'])) { IInterceptor::reg($config['interceptor']); register_shutdown_function(array('IInterceptor', "shutDown")); } }
/** * 设置当前框架正在运行的应用 * @param Object $app 应用对象 */ public static function setApplication($exeApp) { self::$app = $exeApp; }
<?php define('START_TIME', microtime(true)); $iweb = dirname(__FILE__) . "/lib/iweb.php"; $config = dirname(__FILE__) . "/config/config.php"; require $iweb; $iwebApp = IWeb::createWebApp($config)->run();
/** * 设置当前框架正在运行的应用 * @param Object $app 应用对象 */ public static function setApplication($exeApp) { echo 'ddddddddddd<br>'; self::$app = $exeApp; }
/** * @brief 创建WebApplication应用 * @param array $config * @return object Application对象 */ public static function createWebApp($config = null) { self::$app = self::createApp('IWebApplication', $config); return self::$app; }
public function __construct() { echo 'sdfsdfsadfasdfsssssssssssssss<br><br>'; echo IWeb::exeTime() . '<br><br>'; exit; }