定制 sersid/yii2-config 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sersid/yii2-config

最新稳定版本:v1.0.3

Composer 安装命令:

composer require sersid/yii2-config

包简介

Yii2 manage configuration from database

README 文档

README

Manage configuration from database

Installation

One

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist sersid/yii2-config "*"

or add

"sersid/yii2-config": "*"

to the require section of your composer.json file.

Two

Applying migrations

yii migrate --migrationPath=@vendor/sersid/yii2-config/migrations

Three

$config = [
    ...
    'components' => [
        ...
        'config' => [
            'class' => 'sersid\config\components\Config',
            'coding' => '...', // json of serialize. Default 'json'
            'idConnection' => 'db', // The ID of the connection component
            'tableName' => '{{%config}}', //Config table name
            'idCache' => 'cache', // The ID of the cache component. Default null (no caching)
            'cacheKey' => 'config.component', // The key identifying the value to be cached
            'cacheDuration' => 360, // The number of seconds in which the cached value will expire. 0 means never expire. Default 0
        ],
    ]
];

Usage

Once the extension is installed, simply use it in your code by :

Set

Yii::$app->config->set('foo', 'bar');
Yii::$app->config->set('foo', ['bar', 'baz']);
Yii::$app->config->set(['foo' => 'bar']);

Get

Yii::$app->config->get('zyx'); // null
Yii::$app->config->get('zyx', 'default'); // 'default'
Yii::$app->config->get('foo', 'default'); // 'bar'
Yii::$app->config->get(['foo' => 'default']);

Delete

Yii::$app->config->delete('foo');
Yii::$app->config->deleteAll(); // delete all config

Uninstall

Applying migrations

yii migrate/down --migrationPath=@vendor/sersid/yii2-config/migrations

统计信息

  • 总下载量: 2.55k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-10-28