PHP code example of smarteng / yii2-config

1. Go to this page and download the library: Download smarteng/yii2-config 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/ */

    

smarteng / yii2-config example snippets


'components' => [
    'config' => [
        'class' => '\smarteng\config\components\Config',
        'provider' => [
            'class' => '\smarteng\config\providers\DbProvider',
            'tableName' => '{{%config}}',  // by default
            'keyColumn' => 'key',                 // by default
            'valueColumn' => 'value',             // by default
        ]
    ],
    ...
]

$isSet = \Yii::$app->config->set('commission', '10');   // can throw an exception
$isSet = \Yii::$app->config->safeSet('commission', '10');   // return false if something went wrong

$isSet = \Yii::$app->config->exists('commission');      // return true if key exists
$value = \Yii::$app->config->get('commission');         // return '10';