100idea/yii2-settings

Component to store application settings in cache and database as a key-value pair

1.1.0 2016-02-08 18:47 UTC

README

Build Status BSD-3 licensed

Component "Settings"

Component to store application settings in cache and database as a key-value pair

Install

Easy way to install this extension to use composer.

First, add this repository in the section repositories in your composer.json file.:

{
    "type": "git",
    "url": "https://github.com/100idea/yii2-settings.git"
}

Then install the extension. To do this, run:

php composer.phar require 100idea/yii2-settings "*"

or add in section require in your composer.json file.

"100idea/yii2-settings": "*"

Configuration Database

To create and update the necessary tables using migration:

yii migrate --migrationPath=@vendor/100idea/yii2-settings/migrations

Configuration application

For quick access to the component, you must add it to the application configuration file Yii2:

...
'components' => [
    ...
    'settings' => [
        'class' => 'idea\settings\Settings',
    ],
    ...
],
...

Using

Once the extension is installed and configured, you can use it. For example:

$s = Yii::$app->settings;
$s->set('main', 'sitename', 'Yii 2.0 example app');
$var = $s->get('main', 'sitename');
$s->delete('main', 'sitename');