yii2 funson86\yii2-setting
Yii2 Setting for other application, especially for Yii2 Adminlte
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require funson86/yii2-setting "*"
or add
"funson86/yii2-setting": "*"
to the require section of your composer.json file.
Usage
Once the extension is installed, simply use it in your code by :
Migration
Migration run
yii migrate --migrationPath=@funson86/setting/migrations
Config /common/config/main.php to use Yii::$app->setting
'components' => [
'setting' => [
'class' => 'funson86\setting\Setting',
],
],
Config backend modules in backend/config/main.php to manage settings
'modules' => [
'setting' => [
'class' => 'funson86\setting\Module',
'controllerNamespace' => 'funson86\setting\controllers'
],
],
Config at backend
backend : http://you-domain/backend/web/setting
Add Your Setting
Setting 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 (11, 0, 'info', 'group', '', '', '', '50'), (21, 0, 'basic', 'group', '', '', '', '50'), (31, 0, 'smtp', 'group', '', '', '', '50'), (1111, 11, 'siteName', 'text', '', '', 'Your Site', '50'), (1112, 11, 'siteTitle', 'text', '', '', 'Your Site Title', '50'), (1113, 11, 'siteKeyword', 'text', '', '', 'Your Site Keyword', '50'), (2111, 21, 'timezone', 'select', '-12,-11,-10,-9,-8,-7,-6,-5,-4,-3.5,-3,-2,-1,0,1,2,3,3.5,4,4.5,5,5.5,5.75,6,6.5,7,8,9,9.5,10,11,12', '', '8', '50'), (2112, 21, 'commentCheck', 'select', '0,1', '', '1', '50'), (3111, 31, 'smtpHost', 'text', '', '', 'localhost', '50'), (3112, 31, 'smtpPort', 'text', '', '', '', '50'), (3113, 31, 'smtpUser', 'text', '', '', '', '50'), (3114, 31, 'smtpPassword', 'password', '', '', '', '50'), (3115, 31, 'smtpMail', 'text', '', '', '', '50');
Use Your Setting
Once you set the value at the backend. Simply access your setting by the following code:
echo Yii::$app->setting->get('siteName');
Preview:

yii2 funson86\yii2-setting的更多相关文章
- Yii2设计模式——Yii2中用到哪些设计模式?
"Yii2设计模式"包含了两个方面的内容:1.设计模式,2.Yii2框架. <设计模式>一书虽然以JAVA语言来表达设计模式的思想,但是设计模式远不限制于某一种特定的语 ...
- Yii2 设计模式——Yii2 中用到哪些设计模式?
Yii 2 设计模式“包含了两个方面的内容:1. 设计模式,2. Yii 2 框架. <设计模式>一书虽然以JAVA语言来表达设计模式的思想,但是设计模式远不限制于某一种特定的语言,而是在 ...
- [Yii2]yiisoft/yii2 2.0.2 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found
composer require "dektrium/yii2-user:0.9.*@dev" 一直安装失败,提示:Your requirements could not be r ...
- yii2框架-yii2局部关闭(开启)csrf的验证
(1)全局使用,我们直接在配置文件中设置enableCookieValidation为true request => [ 'enableCookieValidation' => true, ...
- yii2框架的安装&配置启动
top:环境MacBook 1.通过composer 安装yii2 [yii2需要php的PDO和pdo_mysql扩展,需要确认已安装] a. 首先需要配置composer:我使用的是阿里云的镜像: ...
- PHP框架Yii2.0安装(基础版、高级版)
最近农成也是切入了yiiframework 2.0,就是安装yii2.0就花费了不少的时间,为此做了很多的弯路,特此写一篇博文来给后面学习的同学少走一点的弯路.写的不好的地方欢迎各位学习的同学们能够指 ...
- yii2的安装使用
一.Yii2框架 Yii2框架有基本和高级两种版本,主要区别是高级版已经分好了前台.后台,基本版只有前台 二.归档安装方法 归档安装方发很简单,只需要在官网上下载归档文件后,解压即可使用(但是不使用c ...
- PHPWeb开发相关知识
转载:https://blog.csdn.net/wj610671226/article/details/78426698 正则表达式 作用:分割.查找.匹配.替换字符串 分割符:正斜线(/).has ...
- yii2 开源插件与系统
yii2干货集:https://github.com/forecho/awesome-yii2 商城 samdark/yii2-shop composer global require "f ...
随机推荐
- C# for循环及循环嵌套
格式(for循环四要素:初始条件.循环条件.循环体.状态改变) for (int i=1<初始条件>;i<=n<循环条件>;i++<状态改变>) { < ...
- 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing
1.RangeBase(基类) 的示例Controls/ProgressControl/RangeBaseDemo.xaml <Page x:Class="Windows10.Cont ...
- dede使用方法----如何去掉dede自带的版权
最近有朋友问如何将dede的Power by DedeCms去掉,一来为了安全,二来外链确实有些影响,这里分享下去除方法,需要的朋友可以参考下 自从dedecms织梦系统更新到6.7日的版本,底部 ...
- java项目的划分方式:模块优先还是层优先?
I've seen and had lots of discussion about "package by layer" vs "package by feature& ...
- Leetcode 113. Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given su ...
- 说说markdown和latex的简单比较
latex是纯学术风格,写paper写书用 markdown是程序员风格,写笔记贴代码片段用 简单说,latex适合长篇.精致,比如数学公式.图片位置调整.表格样式调整.而markdown就是粗线条, ...
- Linux安装后的基本配置
1.换源 http://mirrors.zju.edu.cn http://mirrors.aliyun.com http://mirrors.ustc.edu.cn ubuntu替换/etc/apt ...
- Slave2: no datanode to stop(HADOOP_PID_DIR)
HADOOP_PID_DIR 本想在环境变量里设置,在相关文件里直接尹用,但是我想起来那时候的JAVA_HOME都不行,还是一个一个设置吧. 有时候,我们对运行几天或者几个月的hadoop或者hbas ...
- CruiseControl.NET/CCNET配置(SVN+MSBuild+BAT+FTP)
CCNET目前最新版本为1.8.5,官方很久没更新过了,如果投入生成环境使用,建议全部转到Jenkins上. 可以直接在这里下载:http://www.cnblogs.com/EasonJim/p/5 ...
- Bzoj4066 简单题
Time Limit: 50 Sec Memory Limit: 20 MBSubmit: 2185 Solved: 581 Description 你有一个N*N的棋盘,每个格子内有一个整数,初 ...