zoukankan      html  css  js  c++  java
  • 【转】Yii framework config 可以被配置的项目

    转自:http://www.dedecms.cn/post_190.html

    <?php
    
    // 取消下行的注释,来定义一个路径别名
    // Yii::setPathOfAlias('local','path/to/local-folder');
    
    // 这是 Web 应用配置的主体部分。任何可写的
    // CWebApplication 属性可以在这里配置。
    return array(
    
        // protected 目录的基础路径
        // 使用 Yii::app()->basePath 来访问
        'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    
        // 应用的名字
        // 使用 Yii::app()->name 来访问
        'name'=>'My website',
    
        //路径别名
          // 可以是应用内部的路径,也可以是外部资源
          'aliases'=>array(
                'myExternalFramework'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'
                .DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'myexternalframework'
            ),
    
            //building on above for a controller in the external
            //framework you can use the controller map to map the
            //controller path
            'controllerMap'=>array('myController'=>'myExternalFramework.controllers.MyController'),
    
            // 默认的 controller
        'defaultController'=>'site',
    
        // 用户语言(for Locale)
        'language'=>'es',
    
            //信息和视图的语言
            'sourceLanguage'=>'es',
    
        // 使用的字符集
        'charset'=>'utf-8',
    
        // 预载入的应用组件
        'preload'=>array('log'),
    
        // 自动载入的类
        'import'=>array(
            'application.models.*',
            'application.components.*',
        ),
    
        // 可以使用 Yii::app()->params['paramName'] 访问的应用级别的参数
        'params'=>array(
            'adminEmail'=>'info@example.com',
        ),
    
        // 注意:你也可以将配置文件分为多个文件,
        // 例如: db.php, params.php 等等。
        // 你可以这样做:
        // 'params'=>require(dirname(__FILE__).'/params.php'),
        // 在 params.php 中你需要返回这个数组:
        // return array('adminEmail'=>'info@example.com');
    
        // 应用组件的配置
        'components'=>array(
    
            // assets, 参考www.yiiframework.com/doc/api/CAssetManager
            'assetManager'=>array(
                // 改变磁盘上的路径
                'basePath'=>dirname(__FILE__).'/http://www.cnblogs.com/assets/',
                // 改变url
                'baseUrl'=>'/web/assets/'
            ),
    
            // 记录
            'log'=>array(
                // 记录器的类
                'class'=>'CLogRouter',
                // 在哪里存储日志?
                'routes'=>array(
                    array(
                        // 保存到文件中,其他选项是可用的
                        'class'=>'CFileLogRoute',
                        // 什么内容保存到文件中? error 和 warning, info 和 trace 可以增加到这里
                        'levels'=>'error, warning',
                    ),
                ),
            ),
    
            // 用户
            'user'=>array(
                // 启用 cookie-based 验证
                'allowAutoLogin'=>true,
                // 设置需要验证时用户被转到的 url
                // 使用 null 出现 403 HTTP 错误
                'loginUrl'=>null,
                // 设置一个类的名字,
                // 这个类扩展自 CWebUser 并且保存在
                // protected/components/<classname> 中。
                // 查阅www.yiiframework.com/doc/cookbook/60/
                'class' => 'WebUser',
            ),
    
            // 数据库
            'db'=>array(
                // 使用 mysql
                'connectionString'=>'mysql:host=example.com;dbname=my_db',
                'username'=>'my_user',
                'password'=>'my_password',
                // 设置连接的字符集
                'charset'=>'utf8',
                // 使用 sqlite
                // 'connectionString'=>'sqlite:'.dirname(__FILE__).'/../data/blog.db',
                //'charset'=>'utf8',
                'schemaCachingDuration'=>'duration in seconds',
            ),
    
            // 缓存
            'cache'=>array(
                'class'=>'A cache class, like: system.caching.CApcCache',
            ),
    
            // url
            'urlManager'=>array(
                // URL 格式。必须是 'path' 或 'get'。
                // path: index.php/controller/action/attribute/value
                // get: index.php?r=controller/action&attribute=value
                'urlFormat'=>'path',
                // 显示为www.example.com/index.php/controller/action
                // 或www.example.com/controller/action
                'showScriptName' => true,
                // 转向指定的 url 到你想要的 controller 的规则
                // 查阅www.yiiframework.com/doc/guide/topics.url
                'rules'=>array(
                    //www.example.com/home代替www.example.com/site/index
                    'home'=>'site/index',
                    'post/<id:\d+>'=>'post/show',
                ),
            ),
                    // 你可以使用 scriptMap 来配置脚本来自哪里。
                    //If you use the split configurations for development and production you can
                    // have different maps in each and then just load the file and it'll
                    // load the appropriate file depending on the configuration your running.
                    // 对于一个生产环境的配置,如下
                    'clientScript'=>array(
                          'scriptMap'=>array(
                              'register.js'=>'site.min.js',
                              'login.js'=>'site.min.js',
                          ),
                    ),
                    // 对于一个开发环境,可以这样做
                    'clientScript'=>array(
                          'scriptMap'=>array(
                              'register.js'=>'register.js',
                              'login.js'=>'login.js',
                          ),
                    ),
        ),
    );
    ?>
  • 相关阅读:
    双重检查锁定(Double-Checked Locking)与延迟初始化(Lazy Initialization)
    Spring Cloud Zookeeper搭建实例
    Spring Boot读取properties
    快速搭建单机版Spring Cloud EurekaServer
    MyBatis PageHelper分页插件
    MyBatis Generator 逆向工程插件
    快速搭建单机版Spring Cloud EurekaServer
    什么是JWT令牌认证?
    Spring Boot高频面试题:Spring Boot执行原理
    SOLID原则都不知道,还敢说自己是搞开发的!
  • 原文地址:https://www.cnblogs.com/fzzl/p/2876220.html
Copyright © 2011-2022 走看看