larva/hyperf-settings

This is hyperf settings module.

2.0.0 2023-11-21 13:44 UTC

This package is auto-updated.

Last update: 2024-12-21 16:12:04 UTC


README

Stable Version Total Downloads License

适用于 Hyperf 的配置组件。

安装

composer require larva/hyperf-settings -vv

发布迁移文件

php ./bin/hyperf.php vendor:publish larva/hyperf-settings

使用

快捷使用

// 获取
$setting = settings('xx.aa', null);
//设置
settings()->set('xx.aa', 'value', 'string');
settings()->set('xx.bb', '1', 'bool');

或者直接使用实例

/** @var \Larva\Settings\SettingsRepository $settings
$settings = ApplicationContext::getContainer()->get(SettingsRepository::class);
// 获取
$setting = $settings->get('xx.aa', null);
$sets = $settings->section('xx');

var_dump($sets);
var_dump($setting);

//设置
$settings->set('xx.aa', 'value', 'string');
$settings->set('xx.bb', '1', 'bool');

if($settings->has('xx.bb')) {
  //配置存在
}

//重载配置
$settings->refresh();
//删除配置
$settings->forge('xx.bb');