armincms/option 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

armincms/option

Composer 安装命令:

composer require armincms/option

包简介

The armincms option package.

README 文档

README

A key-value storage for laravel

Table of Contents

Introduction

Armincms Option is a package for store key-value. with this package, you can store values by key and tag in the simplest way into multiple storages.

Installation

To get started with Armincms Option, first run:

    composer require armincms/option

Then publish configuration:

    php artisan vendor:publish --tag=armincms.option

This command publishes config and migration file into the appropriate path.

Configuration

This package supports file and database storage for storing data. The default storage is file. for change the storage type you have two way:

  • With .env file: OPTION_DRIVER=database
  • With Config respository: Config::set('option.default', 'file')

Attention 1: if you want use database storage you should run php artisan migrate in console.

Attention 2: For access to option-manager by laravel container you can use app('armincms.option')

Attention 3: For simple coding: you can use helper option() insteadof app('armincms.option')

Single Storing

There exists two way for storing single data:

  • first: option()->put(key, value)

  • second: option()->key = value

Mass Storing

For mass storing data use the followings method:

option()->putMany([
	key1 => value1,
	key2 => value2,
])  

Grouped Data

For grouping many option, can pass tag parameter when storing a data:

app('armincms.option')->put(key, value, tag)

Also; it's possible to attach a tag into data when mass storing:

app('armincms.option')->putMany([
	key1 => value1,
	key2 => value2,
], tag)

Retrieving

There exist many ways to retrieve your data.you can retrieve your data, single or multiple.

single retrieving:

To retrieve an option, you can use option()->key. but if you need default value for missed values; you can use option(key, default) or option()->get(key, default) .

multiple retrieving:

Also, retrieving multiple options is not difficult. you can retrieve many values by its keys with the many method; like option()->many(keys). If you need default value for missed values; you can pass an associative array of keys and default values; like following:

	option()->many([
		key1 => key1-default, 
		key2 => key2-default,
		key3,
		key4,
		key5 => key5-default
	])

And you can retrieve tagged values with option()->tag(tag).

Retrieving From Other Storage

For store an option into none default driver with assumption that default driver is database; follow this:

app('armincms.option')->store('file')->put(key, value, tag)
app('armincms.option')->store('file')->many([key1, key2], tag)

For retrieve you can use this:

app('armincms.option')->store('file')->get(key, default)
app('armincms.option')->store('file')->tag(tag) 
app('armincms.option')->store('file')->many(keys)  

Check For Existence

If you want to check for existance of an option ; you can use helper option_exists(key) or option()->has(key).

armincms/option 适用场景与选型建议

armincms/option 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.36k 次下载、GitHub Stars 达 15, 最近一次更新时间为 2019 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 armincms/option 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 armincms/option 我们能提供哪些服务?
定制开发 / 二次开发

基于 armincms/option 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 15
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-07