PHP code example of solutosoft / yii-settings

1. Go to this page and download the library: Download solutosoft/yii-settings library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

solutosoft / yii-settings example snippets


'components' => [
    'settings' => [
        'class' => 'solutosoft\settings\Settings',
    ],
],

$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();



'components' => [
    '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');