YII framework configuration

Written by webscriptz on 20/12/2009 – 23:47

I’m toying with the Yii Framework for some time now and even if i cost me a lot of anger and frustration in the beginning I’m starting to like it more and more, alas I do have to say that the documentation isn’t always that clear and for someone who begins or who’ll write some large applications the configuration file can be a hassle so here’s my solution:

Brake down the configuration file in multiple files, this will give you some speed disadvantage and some will  saying that I’m raping Yii framework purpose for speed but at least to me it seems more clear

This is the protected.config/main.php

dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'WEBSITENAME',
'modules'=>array(
'users'=>array(
//sub modules in the module users
'modules'=>array(
'messaging',
'profile',
'dashboard',
)
),
'about',
'forums',
),

// preloading 'log' component active loading
'preload'=>array('log'),

// autoloading model and component classes lazy loading
// I make the difference between CformModel and CActiveRecord
'import'=>array(
'application.models.*',
'application.models.forms.*',
'application.models.database.*',
),

// application components
'components'=>array(
// enable cookie-based authentication
'user'=>array('allowAutoLogin'=>true),

// data relinquished to database.php
// for easy access and usability as also for the future
// installation procedure, it's less to write to a file
'db'=>include(dirname(__FILE__).'/database.php'),

// for a better overview we exculded url routes to a seperate file
'urlManager'=>include(dirname(__FILE__).'/routes.php'),

//authentication component needs data from db for CdbConnection
'authManager'=>array(
'class'=>'CDbAuthManager',
'connectionID'=>'db',
'defaultRoles'=>array('authenticated', 'guest'),
),

//security measures
'request'=>array(
'enableCsrfValidation'=>true,
'enableCookieValidation'=>true,
),
),

// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
// uncomment the following if you want static params in the application
//'params'=>array(include(dirname(__FILE__).'/params.php'))
);

database.php

'CDbConnection',
'connectionString'=>'mysql:host=localhost;dbname=mysql',
//'connectionString'=>'pgsql:host=localhost;port=5432;dbname=mysql',
'username' => 'root',
'password' => '',
);
?>

routes.php

'path', // path or get
'urlSuffix' => '', //.html .whateverextentionyouwant
'showScriptName' => true,
'rules'=>array(
'users/recovery/perimeterSecurity/'=>'users/recovery/perimeterSecurity',
),
);
?>

param.php

2012: a parody at the end

11/11/2009 – 23:51

Delicious.com served this last thing and unfortunately i can't keep my skepticism to myself;  please read it first, it really collects two point of views and all the events concerning. It's ...

Register & Yii projects

24/09/2009 – 23:09

So, I think ti's time for some updates on the website. I has been a bit wild the last 3 weeks. School has started yet again and I had a project ...

The view of tomorrow

12/09/2009 – 19:34

This is a video of apparently almost 20 years ago but look at it, it's really has happend. Google Video Tablet Newspaper

Yii framework very first findings

07/09/2009 – 22:46

Yii framework (yiiframework.com) is a very fast php5 framework. At first it seems like a jungle in the code, everything is put into motion to make the framework very fast. ...

About Me

Here I'll share my knowledge, discovery and experience related to my hobby and work. Most articles on this site are related to blog design, short reviews, tips and make money online. More

Find entries :