Using the configuration file, explain what can be configured.

The purpose of this post is to let anyone quickly find how to accomplish a configuration task, and list here all the posibilities of the config.php file and also link to pages that explain how is each thing implemented.

Everyone is welcome to add here configuration rules that haven't been specified or links to other documentation.

The configuration file:


// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	// the base path to the protected folder
	// access it using Yii::app()->basePath
	// name of application
	// access it using Yii::app()->name
	'name'=>'My website',
	//aliases to specify shortcuts for paths in your app or
      // perhaps to external resources for your app

        //building on above for a controller in the external 
        //framework you can use the controller map to map the 
        //controller path

        // default controller that will be executed when running the application
	// user language (for Locale)

        //language for messages and views
	// charset to use

	// preloading application components

	// autoloading classes

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	// Note: you can also separate your configuration file into
	// more files, for example: db.php, params.php and so on.
	// You can do it like this example:
	// 'params'=>require(dirname(__FILE__).'/params.php'),
	// and inside the params.php you will return the array:
	// return array('adminEmail'=>'');

	// configuration of application components
		// assets, see
			// change the path on disk
			// change the url
		// logging
			// class of logger
			// where to store logs?
					// store on file, other options are available
					// what to store on file? error and warning, info and trace can be added here
					'levels'=>'error, warning', 
		// user
			// enable cookie-based authentication
			// set the url where user must be redirected if authentication needed
			// use null to force 403 HTTP error 
			// set here the name of a class
			// that extends CWebUser and it is stored in
			// protected/components/<classname>
			// see:
			'class' => 'WebUser',
		// database
			// using mysql
			// set the charset of the connection
			// using sqlite
			// 'connectionString'=>'sqlite:'.dirname(__FILE__).'/../data/blog.db',
			'schemaCachingDuration'=>'duration in seconds',

                // config for db message source here, see
                'messages' => array(
                       'class' => 'CDbMessageSource',

		// caching
			'class'=>'A cache class, like: system.caching.CApcCache',

		// url 
			// the URL format. It must be either 'path' or 'get'.
			// path: index.php/controller/action/attribute/value
			// get: index.php?r=controller/action&attribute=value
			// show 
			// or just
			'showScriptName' => true,
			// rules to redirect a specific url to the controller you want
			// see:
				// instead of
                // you can use the scriptMap to configure where your scripts come from. 
                //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.
                // for a production configuration you can have this
                // for a development configuration you can have this
17 0
Viewed: 82 928 times
Version: 1.1
Category: Tutorials
Written by: atrandafir
Last updated by: Yang He
Created on: Jan 10, 2010
Last updated: 9 years ago
Update Article


View all history