YII framework configuration

Sunday, December 20th, 2009

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

//nothing in it at the moment

A freepascal clock

Saturday, August 30th, 2008

A basical console clock written in freepascal by me, even if it’s an old language, I have to practice on it for school.

Here you got the code, I’ve added little comments but it isn’t a lot. hh = hour mm = minutes ss= seconds

(more…)

C & FPC

Friday, August 29th, 2008

C programming and pascal, that’s what I’m doing for the moment, I have an exam in 5 days, man I hate it.

Just finished a clock in C: you give the time for tomorrow and he’ll count it down. But it’s basic:

#include
#include

int main(int argc, char *argv[])
{
long hh, mm,th, tm, ts;

printf(“Reveil a quelle heure(24) minutes? \t”);
scanf(“%ld”, &hh);
scanf(“%ld”, &mm);

th= hh+24; //ceci pr une journee
tm = 60 – mm;
ts=0;
while(th>=hh)
{
if(ts>0){ts-=1; sleep(1000);}
else if(tm>0){ts=60; tm–;}
else if (th>hh){ts=60; tm=60; th–;}
else if (th=hh){if(ts>0){ts–;}}
system(“cls”);
printf(“%ld : %ld : %ld”, th, tm, ts);

}

system(“PAUSE”);
return 0;
}

I’m more or less pleased but still the infinite refreshments aren’t what I wanted and sorry about the comment but in exercises I don’t use them (more…)

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 :