Yii2 Setting for other application, especially for Yii2 Adminlte
The preferred way to install this extension is through composer.
Either run
php composer.phar require funson86/yii2-setting "dev-master"
or add
"funson86/yii2-setting": "*"
to the require section of your composer.json
file.
Once the extension is installed, simply use it in your code by :
Migration run
yii migrate --migrationPath=@funson86/setting/migrations
'components' => [
'settings' => [
'class' => 'funson86\setting\Settings',
],
],
'modules' => [
'setting' => [
'class' => 'funson86\setting\Module',
'controllerNamespace' => 'funson86\setting\controllers'
],
],
backend : http://you-domain/backend/web/setting
Settings support 3 type of setting: text, password, select.
You could add your setting by migration or insert to table setting
manually.
INSERT INTO `setting` (`id`, `parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order`) VALUES
(1111, 11, 'siteName', 'text', '', '', 'Your Site', '50'),
(3114, 31, 'smtpPassword', 'password', '', '', '', '50'),
(2112, 21, 'commentCheck', 'select', '0,1', '', '1', '50');
Once you set the value at the backend. Simply access your setting by the following code:
echo Yii::$app->settings->get('siteName');