larva/hyperf-settings

This is hyperf settings module.

1.1.0 2022-01-09 14:19 UTC

This package is auto-updated.

Last update: 2022-09-19 15:11:15 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');