Parsing the configuration file of yii 1.0

Source: Internet
Author: User

The configuration file in yii is mainly an entry file, and then

Main. php


<? PHP // cancel the downstream comments to define a path alias // yii: setpathofalias ('local', 'path/to/Local-folder '); // This is the main part of Web application configuration. Any writable // cwebapplication attributes can be configured here. $ Config = array (// The basic path of the protected directory // use yii: APP ()-> basepath to access 'basepath' => dirname (_ file __). directory_separator. '.. ', // Application name // use yii: APP ()-> name to access 'name' => 'my website ', // path alias // It can be an internal application path or an external resource 'aliases' => array ('myexternalframework' => dirname (_ file __). directory_separator. '.. '. directory_separator. '.. '. directory_separator. 'myexternalframework'), // when maintaining the program Subrequests are forwarded to a local directory 'catallrequest' => array ('site/all'). // how can I perform an operation before the application processes the request? Of course, this function method must have an index. PHP 'onbeginrequest' => 'function', // controller path 'controllermap' => array ('mycontroller' => 'myexternalframework. controllers. mycontroller '), // default controller 'defaultcontroller' => 'SITE', // user language (for locale) 'language' => 'es ', // information and view language 'sourcelanguage' => 'els', 'timezone '=> 'Asia/Shanghai', 'Theme' => 'default ', // use the character set 'charset' => 'utf-8', // pre-loaded Application Component 'preload' => Array ('log'), // automatically loaded class 'import' => array ('application. models. * ', 'application. components. * ',), // you can use yii: APP () -> Params ['paramname'] parameter 'params' => require (dirname (_ file __). '/Params. PHP '), // In Params. in PHP, you need to return this array: yii: APP ()-> setparams. Only yii: APP () can be used () -> Params ['xxx'] to access the // return array ('adminemail '=>' [email protected] '); // configure 'components' => array (// assets, refer to www .Yiiframework.com/doc/api/cassetmanager 'assetmanager' => array (// change the disk path 'basepath' => dirname (_ file __). '/.. /.. /assets/', // change the URL 'baseurl' =>'/web/assets/'), 'request' => array ('enablescsrfvalider' => true, // If 'enablecookievalidation '=> true, // prevent cookie attacks ), // cache 'cache' => array ('class' => 'a cache class, like: system. caching. capccache ',), 'session' => array (// MEMC Ache session cache 'class' => 'ccachehttpsession', 'autostart' => 1, 'sessionname' => 'frontend ', 'cookieparms' => array ('lifetime' => '20160301', 'path' => '/', 'domain '=>' .test.com ', 'httpponly '=> '1'), 'cookiemode' => 'only',), // you can use scriptmap to configure where the script comes from. // For the configuration of a production environment, the following 'clientscript' => array ('scriptmap' => array ('register. JS '=> 'site. min. js', 'login. JS '=> 'site. min. js',),), // For a development environment, you can do 'clientscript' => array ('scriptmap' => array ('register. JS '=> 'register. js', 'login. JS '=> 'login. js',),); $ database = require (dirname (_ file __). directory_separator. 'db. PHP '); If (! Empty ($ database) {$ config ['components'] = cmap: mergearray ($ config ['components'], $ database); // yii: APP () -> setcomponents ($ database);} return $ config;

DB. php

<?phpreturn array(    'db' => array(        'connectionString' => 'mysql:host=192.168.1.240;dbname=tttt',        'emulatePrepare' => true,        'username' => 'root',        'password' => '****',        'charset' => 'utf8',    ),    'card' => array(        'class' => 'CDbConnection',//        'connectionString' => 'mysql:host=192.168.1.240;dbname=card',        'emulatePrepare' => true,        'username' => 'root',        'password' => '**',        'charset' => 'utf8',    ),);

Params. php

<? Phpreturn array ('adminmail' => '[email protected]', 'pagesize' => '000000', 'pager' => array ('class' => 'pagerwidget ', 'maxbuttoncount' => 8, 'firstpagelabel '=> 'homepage', 'lastpagelabel' => 'last page', 'nextpagelabel '=> 'Next page ', 'prevpagelabel '=> 'preg', 'header' => '', 'cssfile' => false ,),);

Index. php
Configure environment constants. Different configuration files and debugging levels are called in different environments.

/*** Application environment, optional: development, production, */defined ('app _ env') or define ('app _ env', 'Development '); // change the following paths if necessaryIf (app_env = 'production ') {error_reporting (0); $ yii = dirname (_ file __). '/framework/yiilite. PHP '; defined ('yii _ trace_level') or define ('yii _ trace_level ', 1);} else {$ yii = dirname (_ file __). '/framework/yii. PHP '; // remove the following lines when in production modedefined ('yii _ debug') or define ('yii _ debug', true ); // specify how many levels of call stack shocould be shown in each log messagedefined ('yii _ trace_level ') or define ('yii _ trace_level', 3 );} $ Config = dirname (_ file __). '/protected/config /'. app_env. '. PHP '; require ('path/to/globals. PHP '); // see the attachment require_once ($ yii); yii: createwebapplication ($ config)-> Run ();

Development. php 
Enable weblog, profile, database performance display, database query parameter records, Gii

Production. php 
Enable database structure cache and Disable Error display

<?phpreturn CMap::mergeArray(    require(dirname(__FILE__).'/main.php'),    array(        'components'=>array(            // uncomment the following to use a MySQL database            'log'=>array(                'class'=>'CLogRouter',                'routes'=>array(                    array(                        'class'=>'CFileLogRoute',                        'levels'=>'error, warning',                    )                ),            ),        ),    ));


Parsing the configuration file of yii 1.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.