承接 hasan-ahani/settings 相关项目开发

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

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

hasan-ahani/settings

Composer 安装命令:

composer require hasan-ahani/settings

包简介

Application wide settings stored in your database

README 文档

README

Settings

Settings

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides application wide settings stored in your database

Table of Contents

Installation

You can install the package via composer:

composer require outerweb/settings

Run the install command to publish the migration and the config file:

php artisan settings:install

Usage

This package tries to mimic the Config functionality of Laravel as close as possible.

You can use the Outerweb\Settings\Facades\Setting facade or the setting() helper function to work with your stored settings.

Storing settings

Storing a single setting

use Outerweb\Settings\Facades\Setting;

Setting::set('key', 'value');
// or
setting(['key' => 'value']);
// or
setting()->set('key', 'value');

Storing multiple settings

use Outerweb\Settings\Facades\Setting;

Setting::set([
    'key1' => 'value1',
    'key2' => 'value2',
]);
// or
setting([
    'key1' => 'value1',
    'key2' => 'value2',
]);
// or
setting()->set([
    'key1' => 'value1',
    'key2' => 'value2',
]);

Storing nested settings

You can use "dot" notation to store nested settings:

use Outerweb\Settings\Facades\Setting;

Setting::set('parent.child', 'value');
// or
setting(['parent.child' => 'value']);
// or
setting()->set('parent.child', 'value');

This will store a single table entry with the key parent.child and the value value.

You can also store nested settings using arrays:

use Outerweb\Settings\Facades\Setting;

Setting::set([
    'parent' => [
        'child1' => 'value',
        'child2' => 'value',
    ],
]);
// or
setting([
    'parent' => [
        'child1' => 'value',
        'child2' => 'value',
    ],
]);
// or
setting()->set([
    'parent' => [
        'child1' => 'value',
        'child2' => 'value',
    ],
]);

This will store two table entries:

  • parent.child1 with the value value
  • parent.child2 with the value value

Retrieving settings

Retrieving a single setting

use Outerweb\Settings\Facades\Setting;

$value = Setting::get('key');
// or
$value = setting('key');
// or
$value = setting()->get('key');

This will return the value of the setting stored with the key key. If the setting does not exist, it will return null.

You can also provide a default value that will be returned if the setting does not exist:

$value = Setting::get('key', 'default_value');
// or
$value = setting('key', 'default_value');
// or
$value = setting()->get('key', 'default_value');

This will return default_value if the setting with the key key is null or does not exist.

Retrieving a nested setting

use Outerweb\Settings\Facades\Setting;

$value = Setting::get('parent.child');
// or
$value = setting('parent.child');
// or
$value = setting()->get('parent.child');

This will return the value of the setting stored with the key parent.child.

Retrieving multiple settings via parent key

Imagine you have the following settings stored:

  • parent.child1 with the value value1
  • parent.child2 with the value value2
use Outerweb\Settings\Facades\Setting;

$values = Setting::get('parent');
// or
$values = setting('parent');
// or
$values = setting()->get('parent');

This will return an associative array:

[
    'child1' => 'value1',
    'child2' => 'value2',
]

Retrieving multiple settings

use Outerweb\Settings\Facades\Setting;

$values = Setting::get(['parent.child1', 'parent.child2']);
// or
$values = setting(['parent.child1', 'parent.child2']);
// or
$values = setting()->get(['parent.child1', 'parent.child2']);

This will return an associative array:

[
    'parent.child1' => 'value1',
    'parent.child2' => 'value2',
]

Retrieving all settings

use Outerweb\Settings\Facades\Setting;

$values = Setting::get();
// or
$values = setting()->get();

This will return all settings as an associative array.

Type safety

You can use the following methods to ensure type safety when retrieving settings:

String

use Outerweb\Settings\Facades\Setting;

$value = Setting::string('key');
// or
$value = setting()->string('key');

This will make sure the returned value is a string. Otherwise, it will throw an UnexpectedValueException.

Integer

use Outerweb\Settings\Facades\Setting;

$value = Setting::integer('key');
// or
$value = setting()->integer('key');

This will make sure the returned value is an integer. Otherwise, it will throw an UnexpectedValueException.

Float

use Outerweb\Settings\Facades\Setting;

$value = Setting::float('key');
// or
$value = setting()->float('key');

This will make sure the returned value is a float. Otherwise, it will throw an UnexpectedValueException.

Boolean

use Outerweb\Settings\Facades\Setting;

$value = Setting::boolean('key');
// or
$value = setting()->boolean('key');

This will make sure the returned value is a boolean. Otherwise, it will throw an UnexpectedValueException.

Array

use Outerweb\Settings\Facades\Setting;

$value = Setting::array('key');
// or
$value = setting()->array('key');

This will make sure the returned value is an array. Otherwise, it will throw an UnexpectedValueException.

Collection

use Outerweb\Settings\Facades\Setting;

$value = Setting::collection('key');
// or
$value = setting()->collection('key');

This uses the same logic as array() but returns a Illuminate\Support\Collection instance instead of an array.

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

hasan-ahani/settings 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-21