定制 takethelead/laravel-settings 二次开发

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

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

takethelead/laravel-settings

最新稳定版本:1.5.0

Composer 安装命令:

composer require takethelead/laravel-settings

包简介

Manage config settings through the database

README 文档

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Overwrite config settings with values from the database.

Installation

You can install the package via composer:

composer require takethelead/laravel-settings

In order to use this package you will need to publish its configuration file:

php artisan vendor:publish --provider="TakeTheLead\Settings\SettingsServiceProvider" --tag="config"

And migrate the database

php artisan migrate

Usage

Overwriting values

This package allows you to define config values that should be overwritten with a value from the database. The keys of these config values can be defined in config/laravel-settings.php, where you can find a key overwrites.

How does this work?

Imagine the following config file

<?php 
// config/some-config-file.php
return [
    'key1' => 'fallback_value_for_key_1',
    'key2' => 'fallback_value_for_key_2,
];

In order to overwrite the value for key2 you will have to create a new setting in the database. You can do this by running the following artisan command (or by creating a migration):

// Updates an existing setting or creates a new one if it does not exists.
php artisan laravel-settings:update fallback_value_for_key_2

please note that string values will be stored encrypted

Now that we have created a new setting in the database we have to tell the application to overwrite it. You can do that in config/laravel-settings.php

// ...
'overwrites' => [
    'some-config-file.key2' => 'the_database_setting_key_you_choose_in_the_previous_step',
],
// ....

That's it, whenever you run config('some-config-file.key2') you will get the value from the database instead of the fallback value from the config file.

Does this impact performance?

No it doesn't, we cache all settings. So whenever a setting has been overwritten once, we will cache its query result forever. Unless you change the value of the setting, then we will clear the cache and and we will need to query for that setting once again.

If you cache your configuration files using php artisan config:cache, the overwritten values will aslo be cached and no queries will be performed during a request.

Available artisan commands

Command Description
php artisan laravel-settings:list List all settings
php artisan laravel-settings:update {setting} Update a setting, or creates it if it does not exist

Testing

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2020-10-13