larapp/laravel-options
Composer 安装命令:
composer require larapp/laravel-options
包简介
User options for laravel application
README 文档
README
This package simplifies working with user options of your laravel application. The options are saved in two places:
- default options (directives) are in config / options.php
- user options (directives) are stored in option table
When set, the default options will be overwritten by the corresponding user options. This override can be disabled by default, or it can be disabled in developer mode.
All values are cached and the number of database queries is minimized. When you save a new value (or delete an existing value), the cache is regenerated. The data is always fresh.
Installation
Install the package via composer:
$ composer require larapper/laravel-options
Run migrations
Run the following command to run migrations.
$ php artisan migrate
Publish config
Run the following command to publish configs.
$ php artisan vendor:publish --provider="Larapp\Options\OptionsServiceProvider" --tag=options
Create new default directives
The default directives are stored in config / options.php
return [ 'some-directive' => 'some value', ];
Create users directive
The user options are accessed like any other object. Example to create:
$option = new \Larapper\Options\Model\Option(); $option->name = 'some-directive'; $option->type = 'string'; $option->value = 'some user value'; $option->save();
Use options
You can determine the value of a directive using the standard config function:
$value = config('options.some-directive');
Refresh cache
Command
$ php artisan options:clear
Code
use Larapp\Options\Facade\Options; Options::refresh();
Casting values
Everything is stored in the database as text. When the values are read, the type is automatically cast. You can control this cast in config / options-package.php
Package setting
See config/options-package.php for setting package behavior.
After its change you MUST refresh the cache!
Versions
- 0.1.0 First version
- 0.2.0 Add cache driver to package config
larapp/laravel-options 适用场景与选型建议
larapp/laravel-options 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 10 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 larapp/laravel-options 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 larapp/laravel-options 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-15