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#-WinForm-三级联动
三级联动 - 查询地区,选择省份自动显示该省份的市.区县 有如下一个数据库 一.写查询方法 public class ChinaData { SqlConnection conn = null; Sq ...
- BZOJ 1105: [POI2007]石头花园SKA
1105: [POI2007]石头花园SKA Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 628 Solved: 182[Submit][Stat ...
- ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet
严重: Context initialization failedorg.springframework.beans.factory.BeanDefinitionStoreException: Fai ...
- CodeForces 37E Trial for Chief
Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Description Having ...
- PHP解释器引擎执行流程 - [ PHP内核学习 ]
catalogue . SAPI接口 . PHP CLI模式解释执行脚本流程 . PHP Zend Complile/Execute函数接口化(Hook Call架构基础) 1. SAPI接口 PHP ...
- Objective-C 利用OC的消息机制,使用Method Swizzling进行方法修改
功能:修改父类不可修改函数方法,函数方法交换 应用场景:假如我们使用的他人提供一个的framework,.m已被打包成二进制.a无法修改源码,只留下.h头文件,那假如代码中某个函数出现了问题可以通过这 ...
- Mac配置一些开发环境(随时补充)
Mac安装mysql并启动 brew install mysql mysql.server start /usr/local/Cellar/mysql/5.6.10/support-files/mys ...
- Beta版本冲刺第七天 12.13
一.站立式会议照片: 二.项目燃尽图: Android端 后台 三.项目进展: 成 员 昨天完成任务 今天完成任务 问题困难 心得体会 胡泽善 用户评价的查看以及审核 用户详情的加入,并且修改了一些卡 ...
- Docker探索系列2之镜像打包与DockerFile
preface docker基本入门以后,可以试试打包docker镜像与dockerfile了 docker镜像 docker hub仓库有2类仓库,用户仓库和顶层仓库,用户仓库由docker用户创建 ...
- 今天接触枚举类型,感觉是C里面应该才有的东西
遍历枚类型的方法: public static EActChannel getEnumByCode(int code) { for (EActChannel enm : EActChannel.val ...