razonyang / yii2-setting
Yii2 Setting Manager
Installs: 3 994
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: ^7.1
- yiisoft/yii2: ~2.0.13
Requires (Dev)
- codeception/codeception: ^3.0
- codeception/verify: ^1.1
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-11-21 21:04:19 UTC
README
Installation
composer require razonyang/yii2-setting
Usage
Configuration:
return [ // console 'controllerMap' => [ 'migrate' => [ 'migrationNamespaces' => [ 'RazonYang\Yii2\Setting\Migration', ], ], ], 'components' => [ // common 'settingManager' => [ 'class' => \RazonYang\Yii2\Setting\DbManager::class, 'enableCache' => YII_DEBUG ? false : true, 'cache' => 'cache', 'mutex' => 'mutex', 'duration' => 600, 'db' => 'db', 'settingTable' => '{{%setting}}', ], ], ];
Migration:
$ yii migrate
$settingManager = Yii::$app->get('settingManager'); // fetch by ID $value = $settingManager->get($id, $defaultValue); // defaultValue is optional // fetchs all settings $settings = $settingManager->getAll(); // flush cache $settingManager->flushCache();