Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/solutosoft/yii-settings
Yii Settings Extension
https://github.com/solutosoft/yii-settings
database settings yii2 yii2-extension
Last synced: about 1 month ago
JSON representation
Yii Settings Extension
- Host: GitHub
- URL: https://github.com/solutosoft/yii-settings
- Owner: solutosoft
- Created: 2019-04-29T14:43:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-27T10:11:35.000Z (over 4 years ago)
- Last Synced: 2024-11-13T14:53:35.027Z (about 2 months ago)
- Topics: database, settings, yii2, yii2-extension
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
Yii Settings Extension
======================This extension provides support for persistent settings for Yii2.
[![Build Status](https://travis-ci.org/solutosoft/yii-settings.svg?branch=master)](https://travis-ci.org/solutosoft/yii-settings)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/solutosoft/yii-settings/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/solutosoft/yii-settings/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/solutosoft/yii-settings/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/solutosoft/yii-settings/?branch=master)
[![Total Downloads](https://poser.pugx.org/solutosoft/yii-settings/downloads.png)](https://packagist.org/packages/solutosoft/yii-settings)
[![Latest Stable Version](https://poser.pugx.org/solutosoft/yii-settings/v/stable.png)](https://packagist.org/packages/solutosoft/yii-settings)Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist solutosoft/yii-settings
```or add
```json
"solutosoft/yii-settings": "*"
```Configuration
-------------To use the Setting Component, you need to configure the components array in your application configuration:
```php
'components' => [
'settings' => [
'class' => 'solutosoft\settings\Settings',
],
],
```Usage
-----```php
$settings = Yii::$app->settings;$settings->set('key');
$settings->set('section.key');
// Checking existence of setting
$settings->exists('key');// Removes a setting
$settings->remove('key');// Removes all settings
$settings->removeAll();
```Events
------You can use `beforeExecute` event to store extra values and apply extra conditions on command execution
```php
[
'settings' => [
'class' => 'solutosoft\settings\Settings',
'on beforeExecute' => function ($event) {
$event->data = ['user_id' => Yii::$app->user->id];
}
],
],$settings = Yii::$app->settings;
//INSERT (`key`,`value`, `user_id`) INTO `setting` VALUES ('website', 'http://example.org', 1)
$settings->set('website', 'http://example.org');//SELECT `value` FROM `setting` WHER (`settings`.`key` = 'website' and `settings`.`user_id` = 1)
$settings->get('website', 'http://example.org');```