Configuration component is designed for key-value type data storage.
In configuration file
'components' => [
'config' => [
'class' => '\ymaker\configuration\Configuration',
'provider' => [
'class' => '\ymaker\configuration\providers\DbProvider',
'tableName' => '{{%configuration}}', // by default
'keyColumn' => 'key', // by default
'valueColumn' => 'value', // by default
]
],
...
]- Create Class for provider
- Implement
\ymaker\configuration\ProviderInterface - Change in the configuration file on your provider
Db provider example
$isSet = \Yii::$app->config->set('commission', '10'); // can throw an exception
$isSet = \Yii::$app->config->safeSet('commission', '10'); // return false if something went wrong
$isSet = \Yii::$app->config->exists('commission'); // return true if key exists
$value = \Yii::$app->config->get('commission'); // return '10';