yii2-settings ¶
Yii2 settings with database module with GUI manager supported
Installation ¶
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist johnitvn/yii2-settings "*"
or add
"johnitvn/yii2-settings": "*"
to the require section of your composer.json
file.
Usage ¶
Add settings into component config: ¶
'components' => [
'settings'=>[
'class'=>'johnitvn\settings\Settings'
],
],
Ok let see this codesnipet to use: ¶
$settings = Yii::$app->settings;
$value = $settings->get('section,'key');
$settings->set('section','key', 'value', 'integer');
Look at line: ¶
$settings->set($section,$key,$value,$type);
You can use $section for distribute setting such as system,user... And the $type will be use for get settings. This extension have used settype for set the type of a setting when you get it
If you want to manager setting with GUI then add settings into module config: ¶
'modules' => [
'settings' => [
'class'=>'johnitvn\settings\Module',
]
]
And go to localhost/index.php?r=settings/manager/index.php
Hi
I've tried, install with
composer require --prefer-dist johnitvn/yii2-settings "*"
but install libraries like 'MPDF'
and don't find path
'johnitvn\settings\Settings'
in my backend directory
I need some help
Thanks
In the last version when invokes at yii::$app->settings->get('mysection','myvalue') appears a error :
Invalid Configuration – yii\base\InvalidConfigException
Failed to instantiate component or class "cache".
↵
Caused by: ReflectionException
Class cache does not exist
in C:\xampp\htdocs\yii-application\vendor\yiisoft\yii2\di\Container.php at line 429
It solves by edit config file so:
'components'=>[
...
'settings' => [
'class' => 'yii2mod\settings\components\Settings', 'cache'=>['class'=>'yii\caching\FileCache'], //add this line ], ],
It Seems like propertie 'cache' from component :
\vendor\yii2mod\yii2-settings\components\Settings.php
by default is 'Cache' whose is instantiaded and reference the class
yii\caching\Cache , this last class can't instantiate because is a abstract class
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.