2017 © Pedro Peláez
 

yii2-extension yii2-settings

Cms Settings - http://www.yiiframework.com/extension/settings/ rewritten for Yii 2

image

marsoltys/yii2-settings

Cms Settings - http://www.yiiframework.com/extension/settings/ rewritten for Yii 2

  • Thursday, June 16, 2016
  • by marsoltys
  • Repository
  • 2 Watchers
  • 2 Stars
  • 30 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

Yii 2 Settings

Instalation

Composer

composer require "marsoltys/yii2-settings:*"

Configuratoion

Add the component to the web.php config file components section:, (*1)

#...
'settings' => [
            'class'            => 'marsoltys\yii2-settings\CmsSettings',
            'cacheComponentId' => 'cache',
            'cacheId'          => 'global_website_settings',
            'cacheTime'        => 84000,
            'tableName'        => '{{settings}}',
            'dbComponentId'    => 'db',
            'createTable'      => **true**,
            'dbEngine'         => 'InnoDB',
        ],
'cache' => [
    'class' => 'yii\caching\FileCache', // Or any other type of Cache
],
#...

Usage

/*   
* Set a database item:  
* $itemName can be an associative array() in key=>value pairs  ($itemValue="" in this case) 
*/
Yii::$app->settings->set($categoryName, $itemName, $itemValue, $toDatabase=true);  

// Get a database item:  
Yii::$app->settings->get($categoryName, $itemName);  

// Get all items from a category:  
Yii::$app->settings->get($categoryName);

// Delete a database item:  
Yii::$app->settings->delete($categoryName, $itemName);  

// Delete all items from a category:  
Yii::$app->settings->delete($categoryName);  

//Import items from a file:  
$items=include('path/to/file.php');//returns an array() in key=>value pairs  
Yii::$app->settings->set($categoryName, $items);

The component uses something like "lazy loading" for loading items within a category, meaning that the items from a category will be loaded when you request them first time. Beside this, at the end of the request, the items from that requested category are written to cache, so next time when you request them, they will be served from cache., (*2)

Note, the component is smart enough to know itself when a new item/category has been added and refresh the cache accordingly so you don't have to keep track of the items you add to database., (*3)

Basically, in most of the cases, the database will be hit only once, then all items will be served from cache, which means you will get a nice way to manage the project configuration without performance penalties., (*4)

The Versions

16/06 2016

dev-master

9999999-dev

Cms Settings - http://www.yiiframework.com/extension/settings/ rewritten for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

settings yii2 cms

16/06 2016

1.0.1

1.0.1.0

Cms Settings - http://www.yiiframework.com/extension/settings/ rewritten for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

settings yii2 cms

18/01 2016

1.0.0

1.0.0.0

Cms Settings - http://www.yiiframework.com/extension/settings/ rewritten for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

settings yii2 cms