Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/larvatecn/think-settings
适用于 ThinkPHP 的配置组件。
https://github.com/larvatecn/think-settings
setting thinkphp
Last synced: 12 days ago
JSON representation
适用于 ThinkPHP 的配置组件。
- Host: GitHub
- URL: https://github.com/larvatecn/think-settings
- Owner: larvatecn
- License: other
- Created: 2021-05-28T00:51:36.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-11-21T13:54:30.000Z (about 1 year ago)
- Last Synced: 2024-03-22T03:02:43.485Z (9 months ago)
- Topics: setting, thinkphp
- Language: PHP
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# think-settings
适用于 ThinkPHP 6/8 的设置扩展,移植 https://github.com/larvatecn/laravel-settings
[![Packagist](https://img.shields.io/packagist/l/larva/think-settings.svg?maxAge=2592000)](https://packagist.org/packages/larva/think-settings)
[![Total Downloads](https://img.shields.io/packagist/dt/larva/think-settings.svg?style=flat-square)](https://packagist.org/packages/larva/think-settings)## 安装
```bash
composer require larva/think-settings -vv
```## 配置
复制 `vendor/larva/think-settings/database/migrations` 文件夹下的迁移文件到你的迁移文件目录后执行迁移即可。
## 使用
```php
\larva\settings\facade\Settings::has('abv');//判断是否存在\larva\settings\facade\Settings::get('abv');//获取
\larva\settings\facade\settings::set('abv','123456');//设置
\larva\settings\facade\settings::set('abv','1','bool');//设置 bool 类型\larva\settings\facade\settings::set('aliyun.appid','123456');//设置配置组
\larva\settings\facade\Settings::get('aliyun.appid');//获取配置组里的\larva\settings\facade\settings::section('aliyun');//直接获取一个配置组
以上两个方法的结果也可以使用 `settings(string $key = '', string $default = null)` 获取同样的结果
直接使用 `settings()` 空参数也可以获取到 `\larva\settings\facade\settings` 的实例;```