Change config file from an admin page

Hello,

I am a Yii newbie and have a random question.

Currently developing a new website which will consist of two main areas - a frontend for all users and a backend for administrators.

From the backend I would like settings which are currently held in the config/main.php to be configurable from the admin area. For example, a page within the admin backend where the user can connect to a different SQL/Postgres/etc database.

Can someone point me towards a tutorial or example on how to do this?

Thanks,

G

First, I’m not sure if there is right Yii way of doing this but this comes to mind:

Load in the config file manually and save it as an array in a variable with eval. Now you can use the array to view the data. You can change the same values in the same variable then save the array inside the same file the same way you read it.