Yiiフレームワークconfigで構成できる項目

11239 ワード

回転:http://www.dedecms.cn/post_190.
<?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'=>'[email protected]',

    ),



    //   :               ,

    //   : db.php, params.php   。

    //       :

    // 'params'=>require(dirname(__FILE__).'/params.php'),

    //   params.php           :

    // return array('adminEmail'=>'[email protected]');



    //        

    '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',

                      ),

                ),

    ),

);

?>