aurorawebsoftware/asetting 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

aurorawebsoftware/asetting

Composer 安装命令:

composer require aurorawebsoftware/asetting

包简介

ASetting is a Laravel package that allows you to dynamically define your config definitions.

README 文档

README

A2AD6A93-7ED8-4793-BB24-F9CEDDDD45F4-21632-000042AB3BFCB4B4.png

Introduction

ASetting is a Laravel package that allows you to manage settings dynamically in your Laravel applications. With this package, you can organize settings in groups stored in the database, supporting various types of settings for easy management.

Features

  • Introducing an interactive blade page where users can view and modify application settings. With this feature, users will be able to customize the behavior and preferences of the application according to their needs.

Installation

You can add the ASetting package to your Laravel project by following the steps below.

Installation via Composer

Add the package to your project using Composer.

composer require aurorawebsoftware/asetting

Publish Configuration

To publish the configuration file, run the following command:

php artisan vendor:publish --tag=asetting-config

This will add the config/asetting.php file to your project, which contains the configuration settings for the ASetting package.

Migration

Run the migration to create the database table used to store settings:

php artisan migrate

Usage

ASetting Facade

The ASetting Facade allows you to easily manage settings. Below are some basic functions and features provided by the Facade.

group(string $group): self

Used to work with settings in a specific group.

ASetting::group('site')->getValue('title');

groups(array $groups): self

Used to work with settings in multiple groups.

ASetting::groups(['site', 'mail'])->all();

getValue(string $key): int|array|bool|string|null|SettingNotFoundException

Used to get the value of a specific setting.

ASetting::group('site')->getValue('title');

getTitle(string $key): string

Used to get the title of a specific setting.

ASetting::group('site')->getTitle('title');

isVisible(string $key): bool

Used to check the visibility status of a specific setting.

ASetting::group('site')->isVisible('title');

get(string $key): array

Used to get all information about a specific setting.

ASetting::group('site')->get('title');

getValues(array $keys): SettingNotFoundException|array

Used to get the values of a specific setting.

ASetting::group('site')->getValues(['title','name']);

getValues(array $keys): SettingNotFoundException|array

Used to get the values of a specific settings.

ASetting::groups(['site','general'])->getValues(['title','name']);

set(string $key, string|int|bool|array $value, string|null $title = null, bool|null $isVisible = null): bool|array

Used to update or create the value of a specific setting.

ASetting::group('site')->set('title', 'New Title', 'Site Title', true);

delete(string $key): bool|SettingNotFoundException

Used to delete a specific setting.

ASetting::group('site')->delete('title');

all(?string $group = null): array

Used to get all settings grouped by groups or under a specific group.

ASetting::all(); // Get all settings
ASetting::group('site')->all(); // Get all settings under a specific group

destroy(string $group): bool|SettingNotFoundException

Used to delete all settings under a specific group.

ASetting::group('site')->destroy();
ASetting::groups(['site','general'])->destroy();

add(string $group, string $key, string|int|bool|array $value, string $title = null, string $type = 'string', bool $isVisible = null): ASettingModel|SettingNotFoundException

Used to add a new setting.

ASetting::add('site', 'new_setting', 'Value', 'Setting Title', 'string', true);

API Usage

Config

You can define tokens for APIs. You can also configure it by adding your own middleware.

return [
'api_token' => ['YOUR_BEARER_TOKEN_HERE'],
'api_middleware' => [
// YourMiddlewareClass::class
]
];

Endpoint Details

getValue

  • Endpoint: /api/asetting/getValue/{group}/{key}
  • Method: GET
  • Parameters: group (string), key (string)

getTitle

  • Endpoint: /api/asetting/getTitle/{group}/{key}
  • Method: GET
  • Parameters: group (string), key (string)

isVisible

  • Endpoint: /api/asetting/isVisible/{group}/{key}
  • Method: GET
  • Parameters: group (string), key (string)

get

  • Endpoint: /api/asetting/get/{group}/{key}
  • Method: GET
  • Parameters: group (string), key (string)

getValues

  • Endpoint: /api/asetting/getValues
  • Method: POST
  • Parameters: group (string|array), keys (array)

set

  • Endpoint: /api/asetting/set
  • Method: PUT
  • Parameters: group (string), key (string), value (string|array), title (string, optional), is_visible (bool, optional)

add

  • Endpoint: /api/asetting/add
  • Method: POST
  • Parameters: group (string), key (string), value (string|array|bool|int), type (string), title (string), is_visible (bool, optional)

all

  • Endpoint: /api/asetting/all/{group?}
  • Method: GET
  • Parameters: group (string, optional)

delete

  • Endpoint: /api/asetting/delete/{group}/{key}
  • Method: DELETE
  • Parameters: group (string), key (string)

destroy

  • Endpoint: /api/asetting/destroy/{group}
  • Method: DELETE
  • Parameters: group (string)

Error Handling

In case of invalid requests or errors, the API will return a JSON response with a corresponding message and, if applicable, validation errors.

Feel free to copy and paste this documentation into your README file. Adjust the formatting as needed.

ASetting Command

This command allows you to interact with the ASetting package.

Usage

php artisan asetting {group=null} {key=null}

This command allows you to interact with the ASetting package.

  1. Fetch a specific setting value:
php artisan asetting myGroup myKey
  1. Fetch all settings in a specific group:
php artisan asetting myGroup
  1. Fetch all settings:
php artisan asetting

Note

  • If the specified group or key is not found, an exception message will be displayed.
  • The command returns the setting value, which can be a string, array, or other types, based on the configuration.

License

The ASetting package is licensed under the MIT License.

aurorawebsoftware/asetting 适用场景与选型建议

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

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

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

围绕 aurorawebsoftware/asetting 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-29