PHPackages                             gokure/hyperf-settings - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gokure/hyperf-settings

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gokure/hyperf-settings
======================

Persistent settings package for Hyperf

v1.0.0(4y ago)3300MITPHPPHP &gt;= 7.2

Since Jul 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/gokure/hyperf-settings)[ Packagist](https://packagist.org/packages/gokure/hyperf-settings)[ RSS](/packages/gokure-hyperf-settings/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (4)Used By (0)

Persistent settings package for Hyperf
======================================

[](#persistent-settings-package-for-hyperf)

[![Build Status](https://camo.githubusercontent.com/5c0ab077d68e88ab6bab52e1d018c30897be4454676721707696444baec960db/68747470733a2f2f7777772e7472617669732d63692e636f6d2f676f6b7572652f6879706572662d73657474696e67732e7376673f6272616e63683d6d61696e)](https://www.travis-ci.com/gokure/hyperf-settings)[![Latest Stable Version](https://camo.githubusercontent.com/8dcecd73087b11ad4534e833aa9f65e1f538ef2087e60ad9a420ad89fc02950f/68747470733a2f2f706f7365722e707567782e6f72672f676f6b7572652f6879706572662d73657474696e67732f762f737461626c65)](https://packagist.org/packages/gokure/hyperf-settings)[![Total Downloads](https://camo.githubusercontent.com/6edc31f36fcc08defbf87615c9209c65ed361f98420bf266db561f9b61cfcf3c/68747470733a2f2f706f7365722e707567782e6f72672f676f6b7572652f6879706572662d73657474696e67732f646f776e6c6f616473)](https://packagist.org/packages/gokure/hyperf-settings)[![License](https://camo.githubusercontent.com/41aded226574d490fe24f7930e45f8282efda04ce9702b45cd128b9ce9acfc48/68747470733a2f2f706f7365722e707567782e6f72672f616b61756e74696e672f6c61726176656c2d73657474696e672f6c6963656e73652e737667)](LICENSE)

This package allows you to save settings in a more persistent way. You can use the database and/or json file to save your settings.

Installation
------------

[](#installation)

1. Require the `gokure/hypref-settings` package in your `composer.json` and update your dependencies:

```
composer require gokure/hypref-settings
```

2. Publish the config and migration files:

```
php bin/hyperf.php vendor:publish gokure/hypref-settings
```

Usage
-----

[](#usage)

```
$store = $container->get(\Gokure\Settings\SettingManager::class)->getDriver();

$store->set('foo', 'bar');
$store->get('foo', 'default value');
$store->get('nested.element');
$store->forget('foo');
$stores = $store->all();
```

Call `$store->save()` explicitly to save changes made.

You can also to use the `setting()` helper:

```
// Get the `default` store instance
setting();

// Get values
setting('foo');
setting('foo.bar');
setting('foo', 'default value');
setting()->get('foo');

// Set values
setting(['foo' => 'bar']);
setting(['foo.bar' => 'baz']);
setting()->set('foo', 'bar');

// Method chaining
setting(['foo' => 'bar'])->save();
```

### Configuration

[](#configuration)

You can change `config/autoload/settings.php`

```
return [
    'default' => [
        /**
         * Default Store Driver
         *
         * This option controls the default setting connection that gets used while
         * using this setting library.
         *
         * Supported: `FileSystemStore::class` and `DatabaseStore::class`
         */
        'driver' => Gokure\Settings\FileSystemStore::class,

        /**
         * FileSystem Store
         *
         * This option used when the driver is set `FileSystemStore::class`, and
         * make sure the path is writable.
         */
        'path' => BASE_PATH . '/runtime/settings.json',

        /**
         * Database Store
         *
         * This option used when the driver is set DatabaseStore::class.
         */
        'database' => [
            // If set to null, the default connection will be used.
            'connection' => null,
            // Table name.
            'table' => 'settings',
            // Column names in database store.
            'key_column' => 'key',
            'value_column' => 'value',
        ],
    ],
];
```

### Auto Saving

[](#auto-saving)

if you add the middleware `Gokure\Settings\SaveMiddleware` to your `middlewares` list in `config/autoload/middlewares.php`, settings will be saved automatically at the end of all HTTP requests, but you'll still need to call `$store->save()` explicitly in commands, queue workers etc.

### FileSystem Store

[](#filesystem-store)

You can modify the path used on run-time using `$store->setPath($path)`.

### Database Store

[](#database-store)

If you want to use the database as settings storage then you should run the `php bin/hyperf.php migrate`. You can modify the table fields from the `create_settings_table` file in the migrations directory.

#### Extra Columns

[](#extra-columns)

If you want to store settings for multiple users/clients in the same database you can do so by specifying extra columns:

```
$store->setExtraColumns(['user_id' => 1]);
```

where `user_id = 1` will now be added to the database query when settings are retrieved, and when new settings are saved, the `user_id` will be populated.

If you need more fine-tuned control over which data gets queried, you can use the `setConstraint` method which takes a closure with two arguments:

- `$query` is the query builder instance
- `$insert` is a boolean telling you whether the query is an insert or not. If it is an insert, you usually don't need to do anything to `$query`.

```
$store->setConstraint(function($query, $insert) {
	if (!$insert) {
	    $query->where(/* ... */);
	}
});
```

License
-------

[](#license)

Released under the MIT License, see [LICENSE](LICENSE).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

1777d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2db6a5e19964c28865f3c11a012d8b7d68cd38e96c2f4faf7411a83b1f469ae?d=identicon)[gokure](/maintainers/gokure)

---

Top Contributors

[![gokure](https://avatars.githubusercontent.com/u/88591?v=4)](https://github.com/gokure "gokure (18 commits)")

---

Tags

Settingsconfighyperfpersistent

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gokure-hyperf-settings/health.svg)

```
[![Health](https://phpackages.com/badges/gokure-hyperf-settings/health.svg)](https://phpackages.com/packages/gokure-hyperf-settings)
```

###  Alternatives

[akaunting/laravel-setting

Persistent settings package for Laravel

495805.1k7](/packages/akaunting-laravel-setting)[dmishh/settings-bundle

Database centric Symfony configuration management. Global and per-user settings supported.

115254.9k1](/packages/dmishh-settings-bundle)[jbtronics/settings-bundle

A symfony bundle to easily create typesafe, user-configurable settings for symfony applications

9546.7k2](/packages/jbtronics-settings-bundle)[lav45/yii2-settings

This extension helps you to easily store and retrieve data for your application.

1615.0k2](/packages/lav45-yii2-settings)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
