PHP code example of justcoded / yii2-settings
1. Go to this page and download the library: Download justcoded/yii2-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/ */
justcoded / yii2-settings example snippets
'migrate' => [
'migrationPath' => [
'@vendor/justcoded/yii2-settings/migrations'
],
],
'components' => [
'settings' => [
'class' => 'justcoded\yii2\settings\components\DbSettings',
],
],
'bootstrap' => ['log', 'settings'],
// set value
Yii::$app->settings->set('section_name', 'key', 'value');
// get value
$value = Yii::$app->settings->get('section_name', 'key');
'settings' => [
'class' => 'justcoded\yii2\settings\components\DbSettings',
'modelsMap' => [
'section1' => 'app\models\MySettingsForm1',
'section2' => 'app\models\MySettingsForm2',
],
],
public function actions()
{
return [
'actionName' => [
'class' => 'justcoded\yii2\settings\actions\SettingsAction',
'modelClass' => 'app\models\MySettingsForm1',
],
];
}
$value = Yii::$app->settings->section1->myPropertyName;
bash
php composer.phar
php yii migrate --migrationPath=@vendor/justcoded/yii2-settings/migrations