CI基本配置

<?php
defined(‘BASEPATH‘) OR exit(‘No direct script access allowed‘);

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
*/
$config[‘base_url‘]    = ‘http://demo.example.com/‘;

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
*/
$config[‘index_page‘] = ‘index.php‘;/*
|--------------------------------------------------------------------------
| URL suffix
|--------------------------------------------------------------------------
|
| This option allows you to add a suffix to all URLs generated by CodeIgniter.
| For more information please see the user guide:
|
| http://codeigniter.com/user_guide/general/urls.html
*/

$config[‘url_suffix‘] = ‘.html‘;

/*
|--------------------------------------------------------------------------
| Default Language
|--------------------------------------------------------------------------
*/
$config[‘language‘]    = ‘english‘;

/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
*/
$config[‘charset‘] = ‘UTF-8‘;

/*
|--------------------------------------------------------------------------
| Enable/Disable System Hooks
|--------------------------------------------------------------------------
|
| If you would like to use the ‘hooks‘ feature you must enable it by
| setting this variable to TRUE (boolean).  See the user guide for details.
|
*/
$config[‘enable_hooks‘] = TRUE;

/*
|--------------------------------------------------------------------------
| Class Extension Prefix
|--------------------------------------------------------------------------
|
| This item allows you to set the filename/classname prefix when extending
| native libraries.  For more information please see the user guide:
|
| http://codeigniter.com/user_guide/general/core_classes.html
| http://codeigniter.com/user_guide/general/creating_libraries.html
|
*/
$config[‘subclass_prefix‘] = ‘MY_‘;
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
|    0 = Disables logging, Error logging TURNED OFF
|    1 = Error Messages (including PHP errors)
|    2 = Debug Messages
|    3 = Informational Messages
|    4 = All Messages
|
| You can also pass in a array with threshold levels to show individual error types
|
|     array(2) = Debug Messages, without Error Messages
|
| For a live site you‘ll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config[‘log_threshold‘] = 0;

/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/logs/ directory. Use a full server path with trailing slash.
|
*/
$config[‘log_path‘] = ‘‘;

/*
|--------------------------------------------------------------------------
| Log File Extension
|--------------------------------------------------------------------------
|
| The default filename extension for log files. The default ‘php‘ allows for
| protecting the log files via basic scripting, when they are to be stored
| under a publicly accessible directory.
|
| Note: Leaving it blank will default to ‘php‘.
|
*/
$config[‘log_file_extension‘] = ‘‘;

/*
|--------------------------------------------------------------------------
| Date Format for Logs
|--------------------------------------------------------------------------
|
| Each item that is logged has an associated date. You can use PHP date
| codes to set your own date formatting
|
*/
$config[‘log_date_format‘] = ‘Y-m-d H:i:s‘;

/*
|--------------------------------------------------------------------------
| Error Views Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/views/errors/ directory.  Use a full server path with trailing slash.
|
*/
$config[‘error_views_path‘] = ‘‘;

/*
|--------------------------------------------------------------------------
| Cache Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/cache/ directory.  Use a full server path with trailing slash.
|
*/
$config[‘cache_path‘] = ‘‘;

/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| If you use the Encryption class or the Session class you
| MUST set an encryption key.  See the user guide for info.
|
| http://codeigniter.com/user_guide/libraries/encryption.html
| http://codeigniter.com/user_guide/libraries/sessions.html
|
*/
$config[‘encryption_key‘] = ‘564566a54saa4sdads‘;

/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| ‘sess_driver‘                = the driver to load: cookie (Classic), native (PHP sessions),
|    or your custom driver name
| ‘sess_valid_drivers‘        = additional valid drivers which may be loaded
| ‘sess_cookie_name‘        = the name you want for the cookie, must contain only [0-9a-z_-] characters
| ‘sess_expiration‘            = the number of SECONDS you want the session to last.
|   by default sessions last 7200 seconds (two hours).  Set to zero for no expiration.
| ‘sess_expire_on_close‘    = Whether to cause the session to expire automatically
|   when the browser window is closed
| ‘sess_encrypt_cookie‘        = Whether to encrypt the cookie
| ‘sess_use_database‘        = Whether to save the session data to a database
| ‘sess_table_name‘            = The name of the session database table
| ‘sess_match_ip‘            = Whether to match the user‘s IP address when reading the session data
| ‘sess_match_useragent‘    = Whether to match the User Agent when reading the session data
| ‘sess_time_to_update‘        = how many seconds between CI refreshing Session Information
|
*/
$config[‘sess_driver‘]            = ‘cookie‘;
$config[‘sess_valid_drivers‘]    = array();
$config[‘sess_cookie_name‘]        = ‘ci_session‘;
$config[‘sess_expiration‘]        = 7200;
$config[‘sess_expire_on_close‘]    = FALSE;
$config[‘sess_encrypt_cookie‘]    = FALSE;
$config[‘sess_use_database‘]    = FALSE;
$config[‘sess_table_name‘]        = ‘ci_sessions‘;
$config[‘sess_match_ip‘]        = FALSE;
$config[‘sess_match_useragent‘]    = TRUE;
$config[‘sess_time_to_update‘]    = 300;

/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| ‘cookie_prefix‘ = Set a prefix if you need to avoid collisions
| ‘cookie_domain‘ = Set to .your-domain.com for site-wide cookies
| ‘cookie_path‘   =  Typically will be a forward slash
| ‘cookie_secure‘ =  Cookies will only be set if a secure HTTPS connection exists.
| ‘cookie_httponly‘ = Cookie will only be accessible via HTTP(S) (no javascript)
|
*/
$config[‘cookie_prefix‘]    = ‘‘;
$config[‘cookie_domain‘]    = ‘‘;
$config[‘cookie_path‘]        = ‘/‘;
$config[‘cookie_secure‘]    = FALSE;
$config[‘cookie_httponly‘]     = FALSE;

/*
|--------------------------------------------------------------------------
| Standardize newlines
|--------------------------------------------------------------------------
|
| Determines whether to standardize newline characters in input data,
| meaning to replace \r\n, \r, \n occurences with the PHP_EOL value.
|
| This is particularly useful for portability between UNIX-based OSes,
| (usually \n) and Windows (\r\n).
|
*/
$config[‘standardize_newlines‘] = FALSE;

/*
|--------------------------------------------------------------------------
| Global XSS Filtering
|--------------------------------------------------------------------------
|
| Determines whether the XSS filter is always active when GET, POST or
| COOKIE data is encountered
|
*/
$config[‘global_xss_filtering‘] = FALSE;

/*
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
|
| ‘csrf_token_name‘ = The token name
| ‘csrf_cookie_name‘ = The cookie name
| ‘csrf_expire‘ = The number in seconds the token should expire.
| ‘csrf_regenerate‘ = Regenerate token on every submission
| ‘csrf_exclude_uris‘ = Array of URIs which ignore CSRF checks
*/
$config[‘csrf_protection‘] = FALSE;
$config[‘csrf_token_name‘] = ‘csrf_test_name‘;
$config[‘csrf_cookie_name‘] = ‘csrf_cookie_name‘;
$config[‘csrf_expire‘] = 7200;
$config[‘csrf_regenerate‘] = TRUE;
$config[‘csrf_exclude_uris‘] = array();

/*
|--------------------------------------------------------------------------
| Output Compression
|--------------------------------------------------------------------------
|
| Enables Gzip output compression for faster page loads.  When enabled,
| the output class will test whether your server supports Gzip.
| Even if it does, however, not all browsers support compression
| so enable only if you are reasonably sure your visitors can handle it.
|
| Only used if zlib.output_compression is turned off in your php.ini.
| Please do not use it together with httpd-level output compression.
|
| VERY IMPORTANT:  If you are getting a blank page when compression is enabled it
| means you are prematurely outputting something to your browser. It could
| even be a line of whitespace at the end of one of your scripts.  For
| compression to work, nothing can be sent before the output buffer is called
| by the output class.  Do not ‘echo‘ any values with compression enabled.
|
*/
$config[‘compress_output‘] = FALSE;

/*
|--------------------------------------------------------------------------
| Minify
|--------------------------------------------------------------------------
|
| Removes extra characters (usually unnecessary spaces) from your
| output for faster page load speeds.  Makes your outputted HTML source
| code less readable.
|
*/
$config[‘minify_output‘] = FALSE;

/*
|--------------------------------------------------------------------------
| Master Time Reference
|--------------------------------------------------------------------------
|
| Options are ‘local‘ or any PHP supported timezone. This preference tells
| the system whether to use your server‘s local time as the master ‘now‘
| reference, or convert it to the configured one timezone. See the ‘date
| helper‘ page of the user guide for information regarding date handling.
|
*/
$config[‘time_reference‘] = ‘local‘;

/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
|
| If your PHP installation does not have short tag support enabled CI
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
| in your view files.  Options are TRUE or FALSE (boolean)
|
*/
$config[‘rewrite_short_tags‘] = FALSE;

/*
|--------------------------------------------------------------------------
| Reverse Proxy IPs
|--------------------------------------------------------------------------
|
| If your server is behind a reverse proxy, you must whitelist the proxy
| IP addresses from which CodeIgniter should trust headers such as
| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify
| the visitor‘s IP address.
|
| You can use both an array or a comma-separated list of proxy addresses,
| as well as specifying whole subnets. Here are a few examples:
|
| Comma-separated:    ‘10.0.1.200,192.168.5.0/24‘
| Array:        array(‘10.0.1.200‘, ‘192.168.5.0/24‘)
*/
$config[‘proxy_ips‘] = ‘‘;

/* End of file config.php */
/* Location: ./application/config/config.php */

打开 $config[‘compress_output’] = TRUE 选项后,通过view输出的内容自动的就会进行gzip压缩。提速效果很明显。

但是打开后,view中输出时就不能再有 echo 语句,否则会发生错误。

控制器中,可以使用$this->output->set_output($string);来代替echo。

时间: 2024-10-11 17:46:01

CI基本配置的相关文章

CI环境配置

CI:php的MVC框架M(模型model):与数据库打交道的,一般情况下数据库里面的一张表对应一个Model,在里面对应该表的增删改查的操作V(视图view):用户看到的界面,其中很多数据是从数据库读取的C(控制器controller):是M与V之间的桥梁,接收V发过来的请求.调用M的操作数据库的方法.接收M的返回值.把结果显示到V上 去官网上下载相应的压缩包,其中application.system.index.php放到项目的根目录中,启动服务器,如果看到欢迎界面,说明成功. applic

Ci分开配置网站前台后台的方法

CI 2.0 多目录(应用程序)配置. 多目录的意思是指在同一个网站中有多套程序,最简单的例子就是网站的前台展示与后台管理.二者由于在网站功能中分属不同部分,通常会有不同的界面, 用到images/stylesheet/javavascript基本是分开的,所以设置不同目录. 源码下载解压后文件结构如下图,默认是只有一个目录的. 为了达成多目录共享一个CodeIgniter的目标,我们要完成以下步骤: 1. 在application目录下新建子目录admin,将上图中红框标注的5个文件夹复制到a

CentOS6.5配置PHP CI程序

步骤: 1.安装CentOS6.5系统:     1.选择PHP+Mysql环境 2.关闭防火墙和SeLinux     1.chkconfig --level 35 iptables off     2.vi /etc/selinux/config         SELINUX=disabled     3.重启   3.设置静态IP[可在全部配置完成后设置]:     1.vi /etc/sysconfig/network-scripts/ifcfg-eth0     DEVICE=eth

详细说明php的4中开源框架(TP,CI,Laravel,Yii)

ThinkPHP简称TP,TP借鉴了Java思想,基于PHP5,充分利用了PHP5的特性,部署简单只需要一个入口文件,一起搞定,简单高效.中文文档齐全,入门超级简单.自带模板引擎,具有独特的数据验证和自动填充功能,框架更新速度比较速度. 优点:这个框架易使用 易学 安全 对bae sae支持很好提供的工具也很强大 可以支持比较大的项目开发 易扩展 全中文文档 总的来说这款框架适合非常适合国人使用 性能 上比CI还要强一些 缺点:配置对有些人来说有些复杂(其实是因为没有认真的读过其框架源码)文档有

CI框架源码阅读笔记1 - 环境准备、基本术语和框架流程

最开始使用CI框架的时候,就打算写一个CI源码阅读的笔记系列,可惜虎头蛇尾,一直没有行动.最近项目少,总算是有了一些时间去写一些东西.于是准备将之前的一些笔记和经验记录下来,一方面权作备忘,另一方面时刻提醒自己:借鉴和学习才有出路,忘记过去意味着背叛! 基本术语说明 在本文开始之前,有必要对文中反复出现的术语做一个简单的说明,如果你对这一部分已经熟谙,完全可以略过.本文中反复出现和提及的术语包括: 前端控制器(Front Controller): 用于集中控制用户的所有请求的组件,将用户的请求发

CI加载流程小结

无聊,决定水一把. CI(CodeIgniter)是我最早接触的一个框架,到现在也只是用了其中一点零碎的方法.一直想对其流程做个小结,却总是因各种各样的“理由”挨着.看见别人图表齐上阵,没那耐心,就从代码说起吧,权当做个笔记,纪念一下. 看在线的用户手册,也知道,将CI下载下来(最新版本2.2.1),解压到机子上,比如www目录,可改个根目录名(原名CodeIgniter-2.2-stable太长),初步目录文件如下,当然这在是windows下面.    访问下,如localhost/ci/in

nginx rewrite php的CI(CodeIgniter)框架

一. 了解nginx rewrite: 正则表达式匹配,其中: * ~ 为区分大小写匹配    * ~* 为不区分大小写匹配    * !~和!~*分别为区分大小写不匹配及不区分大小写不匹配 文件及目录匹配,其中: * -f和!-f用来判断是否存在文件    * -d和!-d用来判断是否存在目录    * -e和!-e用来判断是否存在文件或目录    * -x和!-x用来判断文件是否可执行 flag标记有: * last 相当于Apache里的[L]标记,表示完成rewrite    * bre

手把手教你使用Travis CI自动部署你的Hexo博客到Github上

简介 这年头要是没有个博客都不好意思给别人说你是程序员,我用XX笔记呀,不行吗?不行,这玩意儿要么不能公开分享,要么公开分享要会员,现在到处都是开源,自己学到了东西都不能分享给需要帮助的人,真是伤心呀.那么今天就来聊聊当你用Hexo搭建了博客,怎么自动更新呢,大家都知道Hexo是需要手动生成HTML静态网页的,虽然命令很少,但是每次写完博客先得推送到git然后在生成静态文件,再推送到服务器,想想我这个心也是醉了,不过看到知乎上还有人带着U盘,我只能呵呵了~,你们耐心真好~ 那我们今天就来说说怎么

基于Travis CI搭建Android自动打包发布工作流(支持Github Release及fir.im)

最近付费购买了Travis CI,Travis CI的收费模式很有意思,不是按项目或者用户,而是按工作进程收费,比如初级版本是$129/月,总共提供2个工作进程.在项目不多的情况下,除了用于跑单元测试外,不免想利用的更充分一些,因此抽空搭建了一套基于Travis CI的Android自动发布工作流. 未自动化前安卓开发总是避免不了这样的工作流程: 开发一些新功能,提交代码 完成一部分功能后,打包一个测试版APK 将测试版APK上传到QQ群 / 网盘 / Fir.im / 蒲公英等 在QQ群或发布