smarteng / yii2-config
Yii2 manage config from database
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 6
Type:yii2-extension
Requires
- yiisoft/yii2: *
Replaces
- bower-asset/inputmask: >=3.2.0
- bower-asset/jquery: >=1.11.0
- bower-asset/punycode: >=1.3.0
- bower-asset/yii2-pjax: >=2.0.0
README
Manage configuration from database
Installation
Either run
php composer.phar require --prefer-dist smarteng/yii2-config "*"
or add
"smarteng/yii2-config": "*"
to the require section of your composer.json
file.
Two
Applying migrations
yii migrate --migrationPath=@vendor/smarteng/yii2-config/migrations
Configuration
In configuration file
'components' => [ 'config' => [ 'class' => '\smarteng\config\components\Config', 'provider' => [ 'class' => '\smarteng\config\providers\DbProvider', 'tableName' => '{{%config}}', // by default 'keyColumn' => 'key', // by default 'valueColumn' => 'value', // by default ] ], ... ]
Create own provider
- Create Class for provider
- Implement
\smarteng\config\components\ConfigInterface
- Change in the configuration file on your provider
Usage
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';
Uninstall
Applying migrations
yii migrate/down --migrationPath=@vendor/smarteng/yii2-config/migrations