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 ...
随机推荐
- 【POJ 3525】Most Distant Point from the Sea(直线平移、半平面交)
按逆时针顺序给出n个点,求它们组成的多边形的最大内切圆半径. 二分这个半径,将所有直线向多边形中心平移r距离,如果半平面交不存在那么r大了,否则r小了. 平移直线就是对于向量ab,因为是逆时针的,向中 ...
- tableView使用的易忘技术点(相对于自己)
1.在tableView设置右向导航指示箭头 cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 2.tableView的系 ...
- springMVC数据验证出现404错误解决办法
今天使用springMVC的数据验证的时候,看似很简单的东西,却有一个很大的陷阱:提交空表单的时候总是出现404错误,但是后台却不给你报任何错.遇到这个错误这个很苦恼,搞了几小时,今天记录并分享一下解 ...
- 77.Android之代码混淆
转载:http://www.jianshu.com/p/7436a1a32891 简介 作为Android开发者,如果你不想开源你的应用,那么在应用发布前,就需要对代码进行混淆处理,从而让我们代码即使 ...
- 【BZOJ-1962】模型王子 DP 猜数问题
1962: 模型王子 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 116 Solved: 66[Submit][Status][Discuss] D ...
- Android成长日记-五大布局
1. 五布局之线性布局LinearLayout 特点:它包含的子控件将以横向或竖向的方式排列 ps:android:gravity=”center|bottom”(gravity允许多级联用) Tip ...
- Android成长日记-仿跑马灯的TextView
在程序设计中有时候一行需要显示多个文字,这时候在Android中默认为分为两行显示,但是对于必须用一行显示的文字需要如何使用呢? ----------------------------------- ...
- android.content.SharedPreferences.edit()
今天在实现一个保存用户设置到SharedPreferences时,出现了一个不能将数据保存到SharedPreferences中的情况.经过仔细的分析得出: android.content.Share ...
- #第一用Markdown编辑器#
Markdown初次使用 This is a simple Markdown editor based on 'Markdown' it's * italic * style. it's also _ ...
- UVA11624Fire!(BFS)
题目链接 题意:帮助joe走出一个大火蔓延的迷宫,其中joe每分钟可往上下左右四个方向之一走,所有着火的格子都会蔓延(空格与着火格有公共边,下一分钟这个空格也会着火).迷宫中有一些障碍格,joe和火都 ...