2017 © Pedro Peláez
 

yii2-extension yii2-config

Yii2 manage configuration from database

image

sersid/yii2-config

Yii2 manage configuration from database

  • Friday, March 6, 2015
  • by Sersid
  • Repository
  • 2 Watchers
  • 1 Stars
  • 1,582 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

Yii2 Config

Manage configuration from database, (*1)

Installation

One

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist sersid/yii2-config "*"

or add, (*4)

"sersid/yii2-config": "*"

to the require section of your composer.json file., (*5)

Two

Applying migrations, (*6)

yii migrate --migrationPath=@vendor/sersid/yii2-config/migrations

Three

$config = [
    ...
    'components' => [
        ...
        'config' => [
            'class' => 'sersid\config\components\Config',
            'coding' => '...', // json of serialize. Default 'json'
            'idConnection' => 'db', // The ID of the connection component
            'tableName' => '{{%config}}', //Config table name
            'idCache' => 'cache', // The ID of the cache component. Default null (no caching)
            'cacheKey' => 'config.component', // The key identifying the value to be cached
            'cacheDuration' => 360, // The number of seconds in which the cached value will expire. 0 means never expire. Default 0
        ],
    ]
];

Usage

Once the extension is installed, simply use it in your code by :, (*7)

Set

Yii::$app->config->set('foo', 'bar');
Yii::$app->config->set('foo', ['bar', 'baz']);
Yii::$app->config->set(['foo' => 'bar']);

Get

Yii::$app->config->get('zyx'); // null
Yii::$app->config->get('zyx', 'default'); // 'default'
Yii::$app->config->get('foo', 'default'); // 'bar'
Yii::$app->config->get(['foo' => 'default']);

Delete

Yii::$app->config->delete('foo');
Yii::$app->config->deleteAll(); // delete all config

Uninstall

Applying migrations, (*8)

yii migrate/down --migrationPath=@vendor/sersid/yii2-config/migrations

The Versions

06/03 2015

dev-master

9999999-dev

Yii2 manage configuration from database

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar Sersid

extension yii2 config

06/03 2015

v1.0.3

1.0.3.0

Yii2 manage configuration from database

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar Sersid

extension yii2 config

04/03 2015

v1.0.2

1.0.2.0

Yii2 manage configuration from database

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar Sersid

extension yii2 config

04/03 2015

v1.0.1

1.0.1.0

Yii2 manage configuration from database

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar Sersid

extension yii2 config

20/11 2014

v1.0.0

1.0.0.0

Yii2 manage configuration from database

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar Sersid

extension yii2 config