Moving config file out of config folder?

Hi there,

Since it is my first post I would like to greet everyone here and just say that Yii is the most powerfull framework I’ve ever seen. Developing an application in it stops being just coding and becomes creating master piece-of-art! :slight_smile:

Got one simple question for the beginning - as in title - is it possible to move config file out of config folder?

I have a very simple application which reuses only ‘main.php’ therefore I wanted to move it one level up, into ‘protected’ folder and change it’s name to ‘config.php’ for example. Of course - I’ve changed proper line in index.php from previous:


$config = dirname(__FILE__).'/protected/config/main.php';

to:


$config = dirname(__FILE__).'/protected/config.php';

But it seems to be NOT working. Even I’m 100% sure that path and file name are correct (in any other case PHP throws file-not-found even before Yii actually start) I got:

CHttpException. Unable to resolve the request "site/error".

If I move this file back to ‘config’ folder but change it to ‘anything.php’ or even ‘abc.xyz’ with proper update of index.php - everything is fine. Even if I rename ‘config’ folder to something else - also OK. Therefore I assume that there is some problem with the thing that config file must a level below ‘protected’ folder. Can anyone confirm this?

For first I thought that the problem lies in that ‘protected’ folder is being protected by .htaccess file. But even removing this file does not change anything and CHttpException appears.

Any idea what up and if there is any possibillity for work around this?

Regards,

Trejder

First of all I really don’t understand why you should do a stuff like that…

Anyway check that in main.php you have a line:




	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',




that should be changed accordingly


	'basePath'=>dirname(__FILE__),

Anyway I don’t see any actual advantage in moving the config file… :D

Hi there,

Thanks for solving my problem! :)

Well… Just to prove myself this is possible? :) Does this answer satisfy you? :)

To be honest, it all about clearity of file/folder structure. I simple don’t like idea of creating separate folder to store just one file in it. And I have only file (‘main.php’ renamed to ‘config.php’) since I’m developing a very small application and thrown away ‘test.php’ and ‘console.php’ config files from that folder. Less clicking is another explanation! :)

On the other hand… why not? Is there any change / security risk since WHOLE ‘protected’ folder is secured via ‘deny from all’ in ‘.htaccess’?

There are a lot of (unkonwn) reasons why one would like to move the config file, or put it in a general form - why one would do things different than the norm.

I for example have a really big business application that is logically split into 3 yii applications (client, admin, management) and instead of duplicating the content of the config file for each application I am simply sharing them throgh a config file that is outside the scope of all yii applications.

I had a similar issue, and I created 2 modules (admin, managment) while client was developed as "basic" controllers.

I found this confortable becasue lot of widget were reuse (tipically in admin/managment there is lot of similar works to do).

Is also possible to redirect all address like

admin.mydomain.com

to a module, like webapp/admin/controller/action

There are some coockbook of Y!! about it.