larva / hyperf-settings
This is hyperf settings module.
2.0.0
2023-11-21 13:44 UTC
Requires
- php: >= 8.0.2
- hyperf/config: ^3.0
- hyperf/database: ^3.0
- hyperf/db-connection: ^3.0
- hyperf/redis: ^3.0
- hyperf/utils: ^3.0
Requires (Dev)
- swoole/ide-helper: ^4.5
README
适用于 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');