定制 satheez/laravel-settings 二次开发

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

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

satheez/laravel-settings

Composer 安装命令:

composer require satheez/laravel-settings

包简介

A database-backed key-value settings store for Laravel.

README 文档

README

Latest Version on Packagist CI Total Downloads

A focused, database-backed key-value settings store for Laravel.

Requirements

  • PHP 8.3 or newer
  • Laravel 12.60 or newer, or Laravel 13.10 or newer

Installation

Install the package:

composer require satheez/laravel-settings

Publish and run the migration:

php artisan vendor:publish --tag=laravel-settings-migrations
php artisan migrate

Publish the configuration when the defaults need to be changed:

php artisan vendor:publish --tag=laravel-settings-config

Usage

Inject the settings contract into application services:

use Satheez\LaravelSettings\Contracts\Settings;

final readonly class UpdateCheckoutConfiguration
{
    public function __construct(private Settings $settings) {}

    public function handle(): void
    {
        $this->settings->set('checkout.enabled', true);
    }
}

The contract provides:

$settings->get('checkout.enabled', false);
$settings->set('checkout.enabled', true);
$settings->setMany([
    'checkout.enabled' => true,
    'checkout.countries' => ['LK', 'US'],
]);
$settings->has('checkout.enabled');
$settings->forget('checkout.enabled');
$settings->all();

all() returns an associative array sorted by key. forget() returns whether a row was deleted.

The facade is available when dependency injection is not practical:

use Satheez\LaravelSettings\Facades\Settings;

Settings::set('checkout.enabled', true);

$enabled = Settings::get('checkout.enabled', false);

Supported Values

Settings may contain JSON-safe values:

  • null
  • booleans
  • integers and finite floats
  • valid UTF-8 strings
  • nested arrays containing supported values

Objects, resources, non-finite floats, and invalid UTF-8 strings are rejected with an UnsupportedSettingValue exception.

Stored null, false, 0, 0.0, empty strings, and empty arrays are real values. The default passed to get() is returned only when the key is absent.

Encryption

New values are encrypted by default with Laravel's application encrypter. Each stored payload records whether it is encrypted, so changing the global setting does not make existing version 2 rows unreadable.

LARAVEL_SETTINGS_ENCRYPTION_ENABLED=true

Keep APP_KEY stable. Data encrypted with a previous key cannot be recovered unless that key remains configured through Laravel's key rotation support.

Cache

Database payloads and missing-key lookups are cached by default:

LARAVEL_SETTINGS_CACHE_ENABLED=true
LARAVEL_SETTINGS_CACHE_STORE=
LARAVEL_SETTINGS_CACHE_PREFIX=laravel-settings
LARAVEL_SETTINGS_CACHE_TTL=3600

Writes refresh affected cache entries. Deletes and legacy migrations invalidate them. Cache backend failures are not swallowed.

Database Configuration

The default table is settings on the application's default connection:

LARAVEL_SETTINGS_DB_CONNECTION=
LARAVEL_SETTINGS_TABLE=settings

The configured table must contain the columns created by the package migration.

Upgrading From Version 1

Version 2 reads existing plain and encrypted version 1 rows without modifying them. Review UPGRADING.md, then validate the conversion:

php artisan laravel-settings:migrate --dry-run

Rewrite legacy rows after the dry run succeeds:

php artisan laravel-settings:migrate

Use --force for non-interactive production deployments and --chunk=500 to control read batch size. The command is transactional and idempotent.

The version 1 helpers and LaravelSettings facade remain available as deprecated compatibility wrappers. New code should use the contract or Settings facade.

Testing

composer check
composer test-coverage

Security

Review SECURITY.md before reporting a vulnerability.

License

The MIT License. See LICENSE.md.

satheez/laravel-settings 适用场景与选型建议

satheez/laravel-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-21