zoukankan      html  css  js  c++  java
  • yii framework config 可以被配置的项目

    http://hi.baidu.com/lossless1009/item/990fdb33a52ffcf1e7bb7a4c

    <?php
    002 
    003 // 取消下行的注释,来定义一个路径别名
    004 // Yii::setPathOfAlias('local','path/to/local-folder');
    005 
    006 // 这是 Web 应用配置的主体部分。任何可写的
    007 // CWebApplication 属性可以在这里配置。
    008 return array(
    009 
    010     // protected 目录的基础路径
    011     // 使用 Yii::app()->basePath 来访问
    012     'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    013 
    014     // 应用的名字
    015     // 使用 Yii::app()->name 来访问
    016     'name'=>'My website',
    017 
    018     //路径别名
    019       // 可以是应用内部的路径,也可以是外部资源
    020       'aliases'=>array(
    021             'myExternalFramework'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'
    022             .DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'myexternalframework'
    023         ),
    024 
    025         //building on above for a controller in the external
    026         //framework you can use the controller map to map the
    027         //controller path
    028         'controllerMap'=>array('myController'=>'myExternalFramework.controllers.MyController'),
    029 
    030         // 默认的 controller
    031     'defaultController'=>'site',
    032 
    033     // 用户语言(for Locale)
    034     'language'=>'es',
    035 
    036         //信息和视图的语言
    037         'sourceLanguage'=>'es',
    038 
    039     // 使用的字符集
    040     'charset'=>'utf-8',
    041 
    042     // 预载入的应用组件
    043     'preload'=>array('log'),
    044 
    045     // 自动载入的类
    046     'import'=>array(
    047         'application.models.*',
    048         'application.components.*',
    049     ),
    050 
    051     // 可以使用 Yii::app()->params['paramName'] 访问的应用级别的参数
    052     'params'=>array(
    053         'adminEmail'=>'info@example.com',
    054     ),
    055 
    056     // 注意:你也可以将配置文件分为多个文件,
    057     // 例如: db.php, params.php 等等。
    058     // 你可以这样做:
    059     // 'params'=>require(dirname(__FILE__).'/params.php'),
    060     // 在 params.php 中你需要返回这个数组:
    061     // return array('adminEmail'=>'info@example.com');
    062 
    063     // 应用组件的配置
    064     'components'=>array(
    065 
    066         // assets, 参考www.yiiframework.com/doc/api/CAssetManager
    067         'assetManager'=>array(
    068             // 改变磁盘上的路径
    069             'basePath'=>dirname(__FILE__).'/../../assets/',
    070             // 改变url
    071             'baseUrl'=>'/web/assets/'
    072         ),
    073 
    074         // 记录
    075         'log'=>array(
    076             // 记录器的类
    077             'class'=>'CLogRouter',
    078             // 在哪里存储日志?
    079             'routes'=>array(
    080                 array(
    081                     // 保存到文件中,其他选项是可用的
    082                     'class'=>'CFileLogRoute',
    083                     // 什么内容保存到文件中? error 和 warning, info 和 trace 可以增加到这里
    084                     'levels'=>'error, warning',
    085                 ),
    086             ),
    087         ),
    088 
    089         // 用户
    090         'user'=>array(
    091             // 启用 cookie-based 验证
    092             'allowAutoLogin'=>true,
    093             // 设置需要验证时用户被转到的 url
    094             // 使用 null 出现 403 HTTP 错误
    095             'loginUrl'=>null,
    096             // 设置一个类的名字,
    097             // 这个类扩展自 CWebUser 并且保存在
    098             // protected/components/<classname> 中。
    099             // 查阅www.yiiframework.com/doc/cookbook/60/
    100             'class' => 'WebUser',
    101         ),
    102 
    103         // 数据库
    104         'db'=>array(
    105             // 使用 mysql
    106             'connectionString'=>'mysql:host=example.com;dbname=my_db',
    107             'username'=>'my_user',
    108             'password'=>'my_password',
    109             // 设置连接的字符集
    110             'charset'=>'utf8',
    111             // 使用 sqlite
    112             // 'connectionString'=>'sqlite:'.dirname(__FILE__).'/../data/blog.db',
    113             //'charset'=>'utf8',
    114             'schemaCachingDuration'=>'duration in seconds',
    115         ),
    116 
    117         // 缓存
    118         'cache'=>array(
    119             'class'=>'A cache class, like: system.caching.CApcCache',
    120         ),
    121 
    122         // url
    123         'urlManager'=>array(
    124             // URL 格式。必须是 'path' 或 'get'。
    125             // path: index.php/controller/action/attribute/value
    126             // get: index.php?r=controller/action&attribute=value
    127             'urlFormat'=>'path',
    128             // 显示为www.example.com/index.php/controller/action
    129             // 或www.example.com/controller/action
    130             'showScriptName' => true,
    131             // 转向指定的 url 到你想要的 controller 的规则
    132             // 查阅www.yiiframework.com/doc/guide/topics.url
    133             'rules'=>array(
    134                 //www.example.com/home代替www.example.com/site/index
    135                 'home'=>'site/index',
    136                 'post/<id:d+>'=>'post/show',
    137             ),
    138         ),
    139                 // 你可以使用 scriptMap 来配置脚本来自哪里。
    140                 //If you use the split configurations for development and production you can
    141                 // have different maps in each and then just load the file and it'll
    142                 // load the appropriate file depending on the configuration your running.
    143                 // 对于一个生产环境的配置,如下
    144                 'clientScript'=>array(
    145                       'scriptMap'=>array(
    146                           'register.js'=>'site.min.js',
    147                           'login.js'=>'site.min.js',
    148                       ),
    149                 ),
    150                 // 对于一个开发环境,可以这样做
    151                 'clientScript'=>array(
    152                       'scriptMap'=>array(
    153                           'register.js'=>'register.js',
    154                           'login.js'=>'login.js',
    155                       ),
    156                 ),
    157     ),
    158 );
    159 ?>

  • 相关阅读:
    Splay 区间操作(二)
    P1351 联合权值
    Splay 区间操作
    P1801 黑匣子_NOI导刊2010提高(06)
    P3620 [APIO/CTSC 2007]数据备份
    T25990 [Wind Festival]Running In The Sky
    P1484 种树
    P4177 [CEOI2008]order
    题解 P2762 【太空飞行计划问题】
    dalao&话
  • 原文地址:https://www.cnblogs.com/zhaoyang-1989/p/3564848.html
Copyright © 2011-2022 走看看