定制 fomvasss/laravel-variables 二次开发

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

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

fomvasss/laravel-variables

最新稳定版本:5.7.0

Composer 安装命令:

composer require fomvasss/laravel-variables

包简介

Dynamic management of variables/configs in Laravel app

README 文档

README

Latest Stable Version Total Downloads License Quality Score

Dynamic management of variables/configs in Laravel app: creating and updating they in database, using cache and artisan commands, replace default Laravel configs, etc.

Installation

Run:

composer require fomvasss/laravel-variables

Publish the config, migration:

php artisan vendor:publish --provider="Fomvasss\Variable\VariableServiceProvider"

Run migrate:

php artisan migrate

Usage

Facade Variable

<?php
Variable::all();
Variable::get('var_key');
Variable::save('app_name', 'My Var');

Use groupped (multilanguages) variables:

<?php
Variable::setGroup('en')->all(); // return Collection!
Variable::setGroup('uk')->get('var_key');
Variable::get('var_key', null, 'en'); 
Variable::get('en|var_key');
Variable::save('uk|var_key', 'UK var');

Use array (json) variables:

Variable::saveArray('links', ['https::google.com', 'https://laravel.com']);   // save PHP array
Variable::getArray('links');    // return default PHP array!

Use cache variables:

Variable::setGroup('uk')->save('app_name', 'Blog');
Variable::setGroup('uk')->useCache(false)->get('app_name');
//or
Variable::get('var_key', null, 'uk', false);

Helpers

variable($name, $default = null, $group = null);

Replace Laravel configs with variables

Set in config/variables.php option config_key_for_vars=vars

Add keys in variable_config array: variable_key => config_key

Console command

variable:all            # Show all variables
variable:get            # Get single variable
variable:save           # Save single variable
variable:cache-clear    # Cache clear all variables

Use cache

Set in config/variables.php option cache.time seconds for cache.

Clear variable cache with console:

php artisan variable:cache-clear

or

php artisan cache:forget laravel.variables.cache

Clear variable cache in controller after update var:

Variable::cacheClear();
//or
\Cache::forget('laravel.variables.cache');

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-13