codeigniter
中文user guide: http://codeigniter.org.cn/user_guide/
英文user guide:
下載解壓后把整個目錄(假設目錄名為cidemo)放到web site里(假設放入root目錄下)即可。
check if it works at http://localhost/cidemo/index.php
注意:使用codeigniter,所有的page都必須經index.php來分配!!
codeigniter hello worldl tutorial: http://codeigniter.com/tutorials/watch/intro/
* 如果你希望通過隱藏 CodeIgniter 文件的位置來增加安全性,你可以修改 system 和 application 目錄的名字,把它改成任何你想改的。如果已經修改了名字,你必須打開你主目錄下面的index.php 文件設置里面的 $system_path 和 $application_folder 變量,把它設成你新改的名字。
為了安全考慮,system和application兩個文件夾應放到網站根目錄(Web Root)以外的地方,這樣瀏覽器就不能夠直接訪問它們。在默認設置下, 在每個文件夾中都有一個.htaccess配置文件以拒絕直接訪問, 但是當把代碼部署到生產環境時最好移除他們,因為生成環境的web服務可能會改變或不支持.htaccess的配置.
如果你移動了以上兩個文件夾,請打開主目錄下的index.php文件并編輯$system_path和$application_folder兩個變量, 最好使用絕對路徑進行替換, 例如:'/www/MyUser/system'.
* 如果不管你在 URL 里面寫什么都只是出現缺省頁面的話,有可能是你的服務器不支持 PATH_INFO 變量,它被用來提供搜索引擎友好的 URL。解決這個問題的第一步是打開application/config/config.php 文件,查找 URI Protocol 信息。在那里推薦你去嘗試一些其他的設置方法。如果這些方法都無效,你就需要讓 CodeIgniter 去強行加一個問號去標記你的 URL。為了做到這點,打開你的 application/config/config.php 文件把里面的:
$config['index_page'] = "index.php";
修改成這樣:
$config['index_page'] = "index.php?";
codeigniter的url segment的命名格式為:
http://example.com/[controller-class]/[controller-method]/[arguments]
數據庫參數的設置在application/config/database.php
code igniter index.php的welcome page的設置在application/config/routes.php
by default welcome controller page
$route['default_controller'] = "welcome";
codeigniter的index.php里的基本設置
define('ENVIRONMENT', 'development'); //當launch時,設置為production
$system_path = 'system'; //"system" folder path
$application_folder = 'application'; //"system" folder path
application/config/config.php的基本設置:
$config['base_url'] = "http://www.cnmiss.cn/"
您網站的網址,codeigniter 會根據這個網址來生成鏈接、表單地址等。
$config['index_page'] = "index.php"
codeigniter 根目錄下的 index.php
文件名,codeigniter 會使用它來生成鏈接地址。如果使用隱藏 index.php
的 URL,將其設置為空字符串:$config['index_page'] = ""。
去掉URL中的index.php的步驟 http://justcoding.iteye.com/blog/547350
$config['uri_protocol'] = "AUTO"
codeigniter 生成 URL 使用的格式,設置為“AUTO”自動探測。如果鏈接不能正常工作,可以嘗試以下值:
PATH_INFO、QUERY_STRING、REQUEST_URI、ORIG_PATH_INFO。
$config['url_suffix'] = ""
codeigniter 產生鏈接時使用的 URL 后綴,如果要實現偽靜態,可以設置 $config['url_suffix'] = ".html"。
$config['language'] = "english"
codeigniter 程序默認使用的語言
$config['charset'] = "UTF-8"
codeigniter 程序默認使用的字符集
$config['enable_hooks'] = FALSE
是否啟用鉤子,鉤子功能使得您可以在不修改系統核心文件的基礎上來改變或增加系統的核心運行功能。
$config['subclass_prefix'] = 'MY_'
設置擴展 codeigniter 類庫時使用的類名前綴
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-'
設置 codeigniter URL 中允許使用的字符,這是一個正則表達式。當訪問者試圖訪問的 codeigniter URL
包含其它字符時,會得到一個警告。應該盡量限制 codeigniter URL
使用的字符來提高安全性,可以有效的過濾注入攻擊。如果設置為空,允許使用所有字符,強烈建議不要這么做。
$config['enable_query_strings'] = FALSE
codeigniter URL 默認使用分段的 URL,此選項也允許 codeigniter
開啟查詢字符串形式 URL。您可以使用查詢字符串來傳遞要訪問的控制器和函數。例如: index.php?c=controller&m=method。codeigniter
默認使用分段的 URL,查詢字符串的 URL
很多特性不被支持。
$config['controller_trigger'] = 'c'
codeigniter 將查詢字符串中此選項對應的值當做 codeigniter
控制器的名字。
$config['function_trigger'] = 'm'
codeigniter 將查詢字符串中此選項對應的值當做 codeigniter
控制器方法的名字
$config['log_threshold'] = 0
啟用錯誤日志,設置記錄哪些類型的錯誤。
0 = 關閉錯誤日志記錄
1 = 記錄錯誤信息
2 = 記錄調試信息
3 = 記錄通知信息
4 = 記錄所有信息
$config['log_path'] = ''
如果您不想使用默認的錯誤日志記錄目錄配置(system/logs/),可以設置完整的服務器目錄。
$config['log_date_format'] = 'Y-m-d H:i:s'
codeigniter 錯誤日志時間格式
$config['cache_path'] = ''
如果您不想使用默認的緩存目錄(system/cache/)來存儲緩存,可以設置完整的服務器目錄
$config['encryption_key'] = ""
codeigniter 使用的密鑰
$config['global_xss_filtering'] = FALSE
是否對輸入數據(GET、POST)自動過濾跨腳本攻擊
$config['compress_output'] = FALSE
啟用Gzip壓縮達到最快的頁面加載速度
$config['time_reference'] = 'local'
設置時間格式:"local"、"GMT"
$config['rewrite_short_tags'] = FALSE
如果您想要使用短標記,但 PHP
服務器不支持,codeigniter 可以通過重寫短標記來支持這一功能。
$config['proxy_ips'] = ''
如果訪問者通過代理服務器來訪問您的網站,您必須設置代理服務器 IP
列表,以識別出訪問者真正的 IP
* 在codeigniter中的url中混合使用querystring和segment
目前測試的結果是codeigniter by default 支持混合的。可以通過
$this->input->get('some_variable', TRUE);
來獲取GET parameter
ref links:
http://stackoverflow.com/questions/2171185/codeigniter-php-framework-need-to-get-query-string
http://codeigniter.com/user_guide/libraries/input.html
另外還有其他solutions:
http://www.askaboutphp.com/58/codeigniter-mixing-segment-based-url-with-querystrings.html/comment-page-1
http://gpiot.com/code-igniter-mixing-segment-based-url-with-get-querystring/
http://www.askaboutphp.com/58/codeigniter-mixing-segment-based-url-with-querystrings.html
http://stackoverflow.com/questions/2171185/codeigniter-php-framework-need-to-get-query-string
http://blog.shian.tw/codeigniter-query-string-get.html
http://jackyrong.iteye.com/blog/897295
下一篇 軟件測試常用的基礎工具