2017 © Pedro Peláez
 

yii2-extension yii2-settings

Simple yii2 component for persistent settings storage

image

olessavluk/yii2-settings

Simple yii2 component for persistent settings storage

  • Wednesday, October 14, 2015
  • by olessavluk
  • Repository
  • 1 Watchers
  • 1 Stars
  • 65 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Settings Component

Simple yii2 component for persistent settings storage, (*1)

Installation:

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

Either run, (*3)

php composer.phar require olessavluk/yii2-settings "*@dev", (*4)

or add, (*5)

"olessavluk/yii2-settings": "*@dev", (*6)

to your composer.json file., (*7)

Usage

Add migration to create table for settings:, (*8)

class m150929_124601_settings extends olessavluk\settings\m150929_122401_settings
{
}

Add the following code in your application configuration:, (*9)

'components' => [
  ...
  /**
   * required for advanced application template,
   * to share cache between frontend and backend
   */
  'frontCache' => [
     'class' => 'yii\caching\FileCache',
     'cachePath' => '@frontend/runtime/cache',
  ],
  'settings' => [
      'class' => '\olessavluk\settings\SettingsComponent',
      'cacheName' => 'frontCache',
      'defaults' => [ //optional default settings
          'app' => [
              'siteName' => 'MyApp',
              'adminEmail' => 'admin@exapmle.com',
              'fromEmail' => 'no-reply@example.com',
          ],
      ],
  ],
  ...
]

Now you can use this component:, (*10)

Yii->$app->settings->get('app', 'siteName');
Yii->$app->settings->delete('app', 'siteName');
Yii->$app->settings->set('app', 'siteName', 'NewSiteName');

The Versions

14/10 2015

dev-master

9999999-dev

Simple yii2 component for persistent settings storage

  Sources   Download

MIT

The Requires

 

by Oles Savluk