Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/razonyang/yii2-setting
Yii2 Setting Manager
https://github.com/razonyang/yii2-setting
Last synced: 20 days ago
JSON representation
Yii2 Setting Manager
- Host: GitHub
- URL: https://github.com/razonyang/yii2-setting
- Owner: razonyang
- License: bsd-3-clause
- Created: 2019-08-06T10:53:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-21T04:56:48.000Z (about 5 years ago)
- Last Synced: 2024-04-14T02:23:41.270Z (7 months ago)
- Language: PHP
- Size: 9.77 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Yii2 Setting Manager
====================[![Build Status](https://travis-ci.org/razonyang/yii2-setting.svg?branch=master)](https://travis-ci.org/razonyang/yii2-setting)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/razonyang/yii2-setting/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/razonyang/yii2-setting/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/razonyang/yii2-setting/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/razonyang/yii2-setting/?branch=master)
[![Latest Stable Version](https://img.shields.io/packagist/v/razonyang/yii2-setting.svg)](https://packagist.org/packages/razonyang/yii2-setting)
[![Total Downloads](https://img.shields.io/packagist/dt/razonyang/yii2-setting.svg)](https://packagist.org/packages/razonyang/yii2-setting)
[![LICENSE](https://img.shields.io/github/license/razonyang/yii2-setting)](LICENSE)Installation
------------```
composer require razonyang/yii2-setting
```Usage
-----Configuration:
```php
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
``````php
$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();
```