首页›MVC 核心›WebCore 初始化三步骤
WebCore 初始化三步骤
__initCommonConfig / __initInput / __initPrivateConfig 依次执行
本页内容
- 第一步 __initCommonConfig
- 第二步 __initInput
- 第三步 __initPrivateConfig
- 注意事项
第一步 __initCommonConfig
| 加载项 | 文件 | 行为 |
|---|---|---|
| 应用级函数 | {@APP}/Common/function.php | loadfile(受 __ignore_common_function 控制) |
| 应用级配置 | {@APP}/Common/config.php | 返回数组则逐个 setConfig |
| 应用级路由 | {@APP}/Common/routes.php | 每个规则经 Route::perfectRoute 加入 __SYSTEM_ROUTES |
第二步 __initInput
创建 new Route(Route::request()) 解析请求;把解析出的 mod/ctl/act 写入 Route::$DEFAULT_MOD/CTL/ACT;将多余路径段(key/value 对)通过 Input::setInputgets() 注入全局输入。
第三步 __initPrivateConfig
| 加载项 | 文件 | 行为 |
|---|---|---|
| 模块级函数 | {@APP}/{模块}/function.php | loadfile |
| 模块级配置 | {@APP}/{模块}/config.php | 返回数组则逐个 setConfig |
running() 调用顺序
public function running($config = array()){
$this->__initCommonConfig(); // 1 应用级公共配置
$this->__initInput(); // 2 输入与路由解析
$this->__initPrivateConfig();// 3 模块级配置
$this->__module_name = $this->__route->getModule();
$this->__ctrl_name = $this->__route->getController();
$this->__action_name = $this->__route->getAction();
$this->__response = new Core\Response\Code200();
$this->bindAction($this->useController()); // 4 控制器执行
$stream = $this->returnLayout($this->stream); // 5 layout 包裹
$this->__response->setHead($this->__heads);
$this->__response->setStream($stream);
$this->__response->flush(); // 6 输出
}注意事项
running($config) 支持 ignore_common_config / ignore_common_function 参数跳过公共加载,常用于 CLI 或特殊请求。
KuoqiPHP v1.05 · 离线静态文档 · 界面基于 KuoqiUI ·
返回首页