Thank you choice yii2-config, The config component for Yii2.
The preferred way to install this extension is through composer.
Either run
componser require --prefer-dist weyii/yii2-config "*"
or add
"weyii/yii2-config": "*"
to the require section of your composer.json
file.
After running
composer update
run
yii migrate --migrationPath=@vendor/weyii/yii2-config/migrations
After that change your main configuration file config/web.php
<?php return [
...
'components' => [
...
'config' => [
'class' => 'weyii\config\DbConfig',
],
...
],
...
];
Once the extension is installed, simply use it in your code by :
Yii::$app->config->set('test.foo.bar', 'hello');
Yii::$app->config->set('test1.foo.bar', 'world');
Yii::$app->config->get('test.foo.bar', 'world');
Yii::$app->config->delete('test1.foo');
Yii::$app->config->delete('test.foo.bar');
print_r(Yii::$app->config->get());