承接 bonk007/system-settings 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bonk007/system-settings

Composer 安装命令:

composer require bonk007/system-settings

包简介

Dynamic settings for application

README 文档

README

Packagist Downloads GitHub License Packagist Stars GitHub forks

  1. Install
  2. How to
  3. Configurable Model
  4. Accepted Value

Install

Install the package using composer

composer require bonk007/system-settings

then run migration

php artisan migrate

that's all ⚡

How to

Set setting's value

settings()->set('<group>.<key>', <value>);

example

settings()->set('global-settings.maintenance_scheduled_at', Carbon::parse('2024-07-01 00:00:00'));

if you need to set some value for specific configurable model (learn: what is configurable model)

settings()->for(<model instance>)
  ->set('<group>.<key>', <value>);

example

settings()->for(\App\Models\Organization::find(6))
  ->set('invoice.number_format', 'INV/{SEQUENCE}/{MONTH}/{YEAR}');

or you can use

settings()->set('<group>.<key>.<table of configurable model>.<primary key>', <value>);

example

settings()->set('invoice.number_format.organizations.6', 'INV/{SEQUENCE}/{MONTH}/{YEAR}');

Get setting's value

settings('<group>.<key>', <default value>);

for specific configurable model

settings()->for(<configurable model>)
  ->get('<group>.<key>', <default value>);

or using simple way

settings('<group>.<key>.<table of configurable model>.<primary key>', <default value>)

example

settings('global-settings.maintenance_scheduled_at');
settings('invoice.number_format.organizations.6');
settings()->for(\App\Models\Organization::find(6))
  ->get('invoice.number_format');

Remove setting

settings->unset('<group>.<key>')

with specific configurable model

settings->unset('<group>.<key>.<table of configurable model>.<primary key>')

or

settings()->for(<configurable model>)
  ->unset('<group>.<key>');

example

settings()->unset('global-settings.maintenance_scheduled_at');
settings()->unset('invoice.number_format.organizations.6');
settings()->for(\App\Models\Organization::find(6))
  ->unset('invoice.number_format');

Configurable Model

Configurable model is a Eloquent Model represents an instance that owns custom configurations value.

How to define

Model should implement \Settings\Configurable::class interface example

class User extends Model implements Configurable
{
  // ...
}

Be careful, using shortcut settings()->set('<group>.<key>.<table of configurable model>.<primary key>', <value>);, there is possibility you will store non-configurable model into settings table, then you can't use settings()->for(\App\Models\Organization::find(6)) for any function.

How it works

Configurable model will be stored as polymorphic relation at settings table. The field columns are configurable_table and configurable_id. By default configurable_id has unsigned bigint type, but you can change the type by define static variable \Settings\Manager::$configurableMorphType value with uuid|int|string at AppServiceProvider before you run artisan migrate.

class AppServiceProvider extends ServiceProvider
{
  public function register()
  {
    // ...
    \Settings\Manager::$configurableMorphType = 'uuid';
  }
}

Accepted Value

  • string
  • boolean
  • double/float
  • integer
  • array
  • \DatetimeInterface
  • Eloquent Model
  • Model Collection
  • Basic Collection

bonk007/system-settings 适用场景与选型建议

bonk007/system-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 67 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 06 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「laravel」 「system-settings」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 bonk007/system-settings 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-14