CI CodeIgniter系統流程

2021-09-06 17:12:29 字數 2879 閱讀 7264

進入框架入口檔案index.php =>

定義應用的當前環境(用於設定錯誤模式):define('environment', 'development');

設定系統檔案目錄名:$system_path = 'system';

定義當前檔名常量:define('self', pathinfo(__file__, pathinfo_basepath));

定義系統目錄路徑常量:define('basepath', str_replace('\\', '/', $system_path));

定義前端控制器檔案路徑常量:define('fcpath', str_replace(self, '', __file__));

定義系統目錄名常量:define('sysdir', trim(strchr(trim(basepath, '/'), '/'), '/'));

載入引導檔案:require_once basepath.'core/codeigniter.php';

---------------------------------@黑眼詩人

---------------------------------

進入系統初始化檔案codeigniter.php =>

set_error_handler('_exception_handler');   //定義乙個自定義錯誤處理程式以便記錄php錯誤

if ( ! is_php('5.3'))

if (isset($assign_to_config['subclass_prefix']) and $assign_to_config['subclass_prefix'] != '')

//設定子類字首

if (function_exists("set_time_limit") == true and @ini_get("safe_mode") == 0)

//設定乙個自由的指令碼執行時間限制

$bm =& load_class('benchmark', 'core');

//例項化benchmark基準類,此類使你可以標記點並計算它們之間時間差,記憶體消耗也可以顯示

$bm->mark('total_execution_time_start');

//基準標記,總執行時間開始:$this->marker['total_execution_time_start'] = microtime();

$bm->mark('loading_time:_base_classes_start');

$ext =& load_class('hooks', 'core');    //例項化hooks鉤子類,提供一種不堆砌來擴充套件基礎系統的機制

$ext->_call_hook('pre_system');     //呼叫指定鉤子pre_system

$cfg =& load_class('config', 'core');   //例項化config配置類,包含管理配置檔案的方法

if (isset($assign_to_config))

$uni =& load_class('utf8', 'core');    //例項化utf8類,對utf-8環境提供支援

$uri =& load_class('uri', 'core');    //例項化uri類,解析uri 和 決定路由

$rtr =& load_class('router', 'core'); //例項化router路由類,解析uri 和 決定路由

if (isset($routing))

$out =& load_class('output', 'core');  //例項化output輸出類,負責傳送最終的輸出到瀏覽器

if ($ext->_call_hook('cache_override') === false)

}$sec =& load_class('security', 'core');  //例項化security安全類

require basepath.'core/controller.php';, //引入 基礎控制器類

function &get_instance()

//引入自定義擴充套件 基礎控制器類

}//載入本地控制器

$bm->mark('loading_time:_base_classes_end');

//基準標記,載入的時間結束:$this->marker['loading_time:_base_classes_end'] = microtime();

安全檢查

$ext->_call_hook('pre_controller');  //呼叫"pre_controller" hook

$bm->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); //基準標記,控制器執行時間標記點

$ci = new $class();  //例項化請求控制器

$ext->_call_hook('post_controller_constructor'); //呼叫"post_controller_constructor" hook

呼叫請求的方法

$bm->mark('controller_execution_time_( '.$class.' / '.$method.' )_end'); //基準標記,控制器執行時間結束標記點

$ext->_call_hook('post_controller');  //呼叫"post_controller" hook

if ($ext->_call_hook('display_override') === false)

$ext->_call_hook('post_system');  //呼叫"post_system" hook

if (class_exists('ci_db') and isset($ci->db))

CI CodeIgniter 框架配置

mvc的組成部分 模型 model 代表你的資料結構。通常來說,你的模型類將包含取出 插入 更新你的資料庫資料這些功能。檢視 view 是展示給使用者的資訊。乙個檢視通常是乙個網頁。控制器 controller 是模型 檢視以及其他任何處理 http 請求所必須的資源之間的中介,並生成網頁。舉例 比...

CI CodeIgniter應用配置明細

1.根url 網域名稱 路徑 必須 2.index檔案 可選,預設index 3.uri協議 可選,預設auto 4.url字尾 可選,預設為空 5.預設語言 可選,預設english 6.字符集 可選,預設utf 8 7.是否支援系統 鉤子 可選,預設false 8.擴充套件類的字尾 可選,預設m...

CI codeigniter 如何防止sql注入

閱讀原文 一般情況下我們只要使用ar和開啟xss就可以防止了。實現方法 1.開啟xss config global xss filtering true 2.使用ar 相信你應該明白了。那麼有的朋友會說為什麼我都用了還是有注入呢?那麼你就要分析其他方面的漏洞了。因為如果你全部使用了ar,那麼你傳進去...