Download the PHP package gokure/hyperf-settings without Composer
On this page you can find all versions of the php package gokure/hyperf-settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gokure/hyperf-settings
More information about gokure/hyperf-settings
Files in gokure/hyperf-settings
Package hyperf-settings
Short Description Persistent settings package for Hyperf
License MIT
Informations about the package hyperf-settings
Persistent settings package for Hyperf
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
-
Require the
gokure/hypref-settings
package in yourcomposer.json
and update your dependencies: - Publish the config and migration files:
Usage
Call $store->save()
explicitly to save changes made.
You can also to use the setting()
helper:
Configuration
You can change config/autoload/settings.php
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
You can modify the path used on run-time using $store->setPath($path)
.
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
If you want to store settings for multiple users/clients in the same database you can do so by specifying extra columns:
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
.
License
Released under the MIT License, see LICENSE.
All versions of hyperf-settings with dependencies
ext-swoole Version >= 4.4
hyperf/config Version ^1.0|^2.0
hyperf/database Version ^1.0|^2.0
hyperf/db-connection Version ^1.0|^2.0
hyperf/utils Version ^1.0|^2.0