Easy Config - main.php

In the process of working with (learning) the Yii Framework, I spent the entire day yesterday trying to track a bug that broke the Automatic Code Generation module. I created several new databases, and kept having the same problem. As it turns out the problem ended up being a misplaced configuration item that I had added at some point during the process. Because of the multi-level nested arrays sometimes four or five levels deep, it is easy to misplace a new item within the hierarchy, particularly if you are new.

Here’s the SOLUTION :


Hope this is useful,

Bill Hernandez

Plano, Texas

I have to disagree on your alternative way being easier to read: it looks like it take 3 times as many lines of code to do the same thing.

I think if you do these two things, the default way is just fine:

  1. Use the tab character for indenting, and keep things properly indented at all times.

  2. Use a good code editor so that when you put your text cursor (the blinking line, whatever you call it) next to a bracket, it highlights the corresponding bracket. This helps find errors in where your brackets/parentheses begin and end. Most of the high-end code editors support this.


return array(


	'name'=>'Razmer Car Parts',















		'loader' => array(

			'class' => 'application.components.shared.Loader'


		'mail' => array(

			'class' => 'application.extensions.mail.Mail',















					'levels'=>'error, warning, info, watch',























			'schemaCachingDuration'=>YII_DEBUG ? 0 : 3600,






			'About us'=>array('site/about'),

			'Contact us'=>array('site/contact'),

			'Privacy Policy'=>array('site/policy'),

			'Terms & Conditions'=>array('site/terms'),




jonah "Advanced Member",

You are not a beginner, In fact your picture says “Advanced Member”, that’s not me…

From a beginner’s perspective, I don’t care if there are three times more lines, until I learn my way around, my method will work fine for me.

It was not my intent to offend anyone, merely to show an alternate way that helped me understand, what’s what and where does it go…

I will save you message and when I get more advanced, I will give it a shot…

Best regards,

Bill Hernandez

Plano, Texas

I don’t think you offended anyone… And I like how you documented all options in the configuration (It’s a nice reference). Also it’s a good thing for people to realize that you can configure it the way you did and that it’s flexible like that


Thanks for taking the time to reply…

I made some changes that accommodate your thoughts, (i.e) I did have an excessive number of lines separating the categories, so I created a second main.php that removed most of the extra divider lines (they were excessive) and also removed a lot of the comments, but did leave the variables that control whether certain items are loaded or not, instead of using the comment/un-comment technique.

If you might have another look and let me know what I can improve, I would be grateful…


Thanks Again,

Bill Hernandez

Plano, Texas

I had posted some information that displayed the highlighted some sample code, and for some reason the highlight routine had slipped by in the cracks during some re-organization. Anyway the sample code is fixed now…


I had tried to get rid of the index.php, so I could have something like :


instead of :


RewriteEngine on

RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ ./$1 [L,QSA]

RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

I changed :

        // This adds the index.php to the end of the url, before the Class/Action

        $aArray['components']['urlManager']['showScriptName'] = true;

to :

        // This removes the index.php to the end of the url, before the Class/Action

        $aArray['components']['urlManager']['showScriptName'] = false;

I looked at the two links below, but still could not remove index.php and have things work correctly.



Wondering what I might be missing in :



Any Ideas ?

do you have apache’s rewrite module enabled?